為什么報錯了呢?我的VIM版本是最新的
tuolei717@ubuntu:~/gaoxiang/Les2$ gcc max.c hello.c -o main.out
hello.c: In function ‘main’:
hello.c:5:13: warning: implicit declaration of function ‘max’ [-Wimplicit-function-declaration]
? int maxNum=max(a1,a2);
tuolei717@ubuntu:~/gaoxiang/Les2$ gcc max.c hello.c -o main.out
hello.c: In function ‘main’:
hello.c:5:13: warning: implicit declaration of function ‘max’ [-Wimplicit-function-declaration]
? int maxNum=max(a1,a2);
2016-06-07
舉報
2016-06-21
這節課的視頻你看到完了嗎,最開始我也和你的情況一樣,但看完這節課的視頻后,這個問題就解決了。
這個錯誤是:調用主函數后,在int maxNum=max(a1,a2)出的錯,因為在hello.c這個源文件中沒有對max()函數聲明,導致主函數運行到這里不知道他是誰,所以應該在主函數調用前加一個:#include "max.c"??? 對這個文件專用。
保存退出后,只需要編譯hello.c一個源文件就行了(gcc hello.c),max.c那個就不用編譯,如果兩個同時編譯,又要出錯了。
編譯完后,會生成a.out可執行文件,然后運行它就OK了。
2016-06-08
沒有應用函數就會報個worning ,你可以在引用庫下面加一個#include"max.c"聲明就可以了