Unresolved External Symbol - How to fix?

前端 未结 4 363
故里飘歌
故里飘歌 2021-01-21 12:48

I\'m pretty new to programming. I have run into this error that I can\'t figure out. You should be able to put in a score and it will use the information that is pre put in the

相关标签:
4条回答
  • 2021-01-21 13:13

    It means that you declared the function to be named checkScore but you defined the function to be named checkGrade. Then when main() tries calling checkScore the compiler says "OK, that was declared above. I'll allow it even though I can't find it. It might be in a different library or source file.". Then it is the responsibility of the linker to find it. Since the linker finds checkGrade but doesn't find checkScore, the linker then throws the error saying undefined reference (main() references checkScore and not checkGrade).

    0 讨论(0)
  • 2021-01-21 13:14

    It appears you have declared your function

    void checkScore( int scores[], int storage[]);
    

    but not actually defined it (giving it a function-body). Define your function like

    void checkScore( int scores[], int storage[]){
    
    }
    

    to make this error go away.

    0 讨论(0)
  • 2021-01-21 13:24

    The problem is that your function definition is named differently to your function declaration:

    void checkScore( int scores[], int storage[]);
    void checkGrade(int scores[], int storage[])
    

    You need to pick one or the other. The compiler gets to your call to checkScore and sees that there is no definition for it. Changing the definition to be called checkScore would fix it.

    0 讨论(0)
  • 2021-01-21 13:29

    Your function checkGrade() below the main()-function should probably be called void checkScore( int scores[], int storage[])

    0 讨论(0)
提交回复
热议问题