2017-03-20 3 views
0

私はCのブランドが新しく、世界中で何が原因であるか把握しようとしています。別の同様の質問は、私は別のライブラリをダウンロードしなければならないと言ったが、それは問題を修正していない。だから、うまくいけば誰かが私の問題に気づくことができる。エラー:c:87 :(。テキスト+ 0x247):R_X86_64_PC32が定義されていないシンボル「course_insert」に対して再配置を切り捨てました

#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 

enum Subject {SER=0, EGR=1, CSE=2, EEE=3} subject; 

struct Course { 
    enum Subject subject; 
    int number; 
    char teacher[1024]; 
    int hours; 
} *course; 


//place to store course information 
struct Course* CourseCollection = NULL; 

//number of courses in the collection. also the index of the next empty element. 
int courseCount = 0; 


void branching(char option); 

void course_insert(struct Course course); 

int main() { 
    char input_buffer; 
    printf("Welcome to ASU Class Schedule\n"); 

    //menu and input loop 
    do { 

     printf("\nMenu Options\n"); 
     printf("------------------------------------------------------\n"); 
     printf("a: Add a class\n"); 
     printf("d: Drop a class\n"); 
     printf("s: Show your classes\n"); 
     printf("q: Quit\n"); 
     printf("\nTotal Credits: %d\n\n", courseCount); 
     printf("Please enter a choice ---> "); 

     scanf(" %c", &input_buffer); 

     branching(input_buffer); 
    } while (input_buffer != 'q'); 

    return 0; 
} 

//takes a character representing an inputs menu choice and calls the appropriate 
//function to fulfill that choice. display an error message if the character is 
//not recognized. 

void branching(char option) { 
    int prefix, courseNum, credits; 
    char instructor; 
    struct Course course1; 

    switch(option) { 
    case 'a' : 
     printf("Adding a class"); 
     printf("\nWhat is the subject (SER=0, EGR=1, CSE=2, EEE=3)? "); 
     scanf(" %d", &prefix); 
     course1.subject = prefix; 
     printf("\nWhat is the course number (e.g. 334)? "); 
     scanf(" %d", &courseNum); 
     course1.number = courseNum; 
     printf("\nHow many credits is the class? "); 
     scanf(" %d", &credits); 
     course1.hours = credits; 
     printf("\nWhat is the name of the teacher? "); 
     scanf(" %s", &instructor); 
     strlcpy(course1.teacher, instructor, 1024); 
     printf(" %s %d", course1.subject, course1.number); 
     courseCount++; 
     course_insert(course1); 
     break; 
    case 'd' : 
     // TODO 
     break; 
    case 's' : 
     // TODO 
     break; 
    case 'q' : 
     printf("Goodbye "); 
     break; 
    default : 
     printf("Error: Invalid Input. Please Try Again. "); 
     break; 
    } 

    void course_insert(struct Course course) { 
     CourseCollection = malloc(sizeof(course)*courseCount); 
    } 
} 
+1

あなたの中括弧をチェック - course_insertはまあ – stdunbar

+0

の分岐内にある、それは私が作っている可能性が非常識な間違いについてでした。ありがとう! – Kendra

答えて

1

問題は構文上のバグです。 course_insert()の関数定義は、関数定義の中括弧の中にあり、branching()です。あなたは、中括弧を修正する必要があります。

void branching (char option) 
{ 
    // Code for function 
} 

void course_insert(struct Course course) 
{ 
    CourseCollection = malloc(sizeof(course)*courseCount); 
} 
関連する問題