求解釋!?。。。。。?/h1>
這個就算把static改為extern還是不能通過,為什么?
這個就算把static改為extern還是不能通過,為什么?
這個就算把static改為extern還是不能通過,為什么?
2015-12-11
因為文件hello.c的printLine()函數和test.c中的say()函數是被相互引用的,因此這兩個函數都應為外部函數,在兩個文件中都必須聲明引用。所以小編的答案是錯誤的!具體代碼如下:
hello.c文件中:
#include <stdio.h>
#include "test.c"?? //引用test.c文件
extern void say();
void printLine()???? //這里定義的方法對嗎?
{
?? printf("**************\n");??
}
int main()
{
??? say();
??? return 0;
}
test.c文件中:
#include <stdio.h>
extern void printLine();
void say(){
??? printLine();
??? printf("I love imooc\n");
??? printf("good good study!\n");
??? printf("day day up!\n");
??? printLine();
}
是的,你應該看看這里的詳細解釋?http://www.xianlaiwan.cn/qadetail/105343
課程通不過可能是本站的問題,最近題目都不能正常判斷正誤。
。。。
http://www.xianlaiwan.cn/qadetail/105343
錯的地方挺多的,這個題目本身就有問題,具體可以看看上面鏈接所說的
舉報
2016-01-22
補充:extern的主要作用不在于定義外部變量或函數,而在于引用定義,如果在其他編譯器中去掉#include”test.c",不然會出現重定義(例如visual studio)。