0

グッドデイオール、

リンクリスト付きの学生情報システムを用意しようとしています。私はcourseという名前のscturctを作成しました。プロセスの挿入用。関数mainでvoidinsertCourse(CourseNodePtr * cr、char * code)を呼び出します。コンパイルすると、これらのエラーが表示されます。「insertCourse」の引数2の互換性のないタイプ。関数「insertCourse」の引数が少なすぎます。誰かがこの問題についてコメントしますか?どうもありがとう..

/* Function Prototypes */
void insertCourse(CourseNodePtr* cr, char* code);

/* Main func starts here */

int main(void)
Course course_code; 


switch (choice) {
             case 1: 
                  insertCourse(&startPtr, course_code);
                  break;



/* Insert course function  */
void insertCourse(CourseNodePtr* cr, char* code)
{
CourseNodePtr newPtr;   /* New node pointer */
CourseNodePtr previousPtr;   /* previous node pointer in list */
CourseNodePtr currentPtr;    /* current node pointer in list */

newPtr = malloc( sizeof(Course) );   /* memory allocation for new node */

if (newPtr != NULL) {
           printf("Pls enter the code number of the course.\n");
           scanf("%s", &(newPtr->code));
           printf("Pls enter the course name.\n"); 
           scanf("%s", &(newPtr->name));
           printf("Pls enter the instructor name.\n"); 
           scanf("%s", &(newPtr->instructor));
           printf("Pls enter the term; Spring or Fall.\n"); 
           scanf("%s", &(newPtr->term));
           printf("Pls enter the year.\n"); 
           scanf("%s", &(newPtr->year));
           newPtr->coursePtr = NULL; 

           previousPtr = NULL; 
           currentPtr = *cr; 

           while ((currentPtr != NULL)  && ( code  > currentPtr->code)) {
                 previousPtr = currentPtr; 
                 currentPtr = currentPtr->coursePtr; 
           }  /* End While */

           if ( previousPtr == NULL ) {
                newPtr->coursePtr = *cr; 
                *cr = newPtr; 
           }   /* End if */
           else {
                previousPtr->coursePtr = newPtr; 
                newPtr->coursePtr = currentPtr; 
           }  /* End else */
    } /* End if */

    else {
         printf( " %c could not be inserted. Memory not enough...\n", code); 
    }  /* End else */
} /* End function insert */                    
4

2 に答える 2

0

あなたは次のように定義course_codeしましたCourse

Course course_code; 

そして、insertCourse()

insertCourse(&startPtr, course_code);

しかし、それは議論でなければなりませんCourseNodePtr*そしてchar*

void insertCourse(CourseNodePtr* cr, char* code)

間違ったタイプの2番目のパラメーターを渡しました。それは違いないCourse

void insertCourse(CourseNodePtr* cr, Course code)
于 2013-01-15T18:54:45.397 に答える
0

insertCourse の 2 番目のパラメーターは型を想定*charしており、型を渡していますCourse

insertCourse(&startPtr, course_code);
------------------------^ here
于 2013-01-15T18:55:50.893 に答える