為什么運行失敗
為什么運行失???求大神指導。
#include <stdio.h>
#include "test.c"? ?//引用test.c文件
extern void printLine()? ? ?
{
? ?printf("**************\n");? ?
}
int main()
{
? ? say();
? ? return 0;
}
為什么運行失???求大神指導。
#include <stdio.h>
#include "test.c"? ?//引用test.c文件
extern void printLine()? ? ?
{
? ?printf("**************\n");? ?
}
int main()
{
? ? say();
? ? return 0;
}
2018-12-15
舉報
2018-12-17
這個是hello.c中的代碼,另外在test.c中 void say() 默認是外部函數,但是在hello.c中第二行又引用了test.c其實是沒必要的。說白了就是人家本來就是外部函數可以直接調用但是你又引用了他的文件。
兩種可以方法解決:
hello.c中把第二行引用test.c注釋掉;
test.c中把void say()定義為內部函數即static?void say() 。
問題倒可以解決,但是并不確定也不明白為什么外部函數和引用文件會有沖突,可能跟編譯器有關吧。?
2018-12-15
hello.c中 #include?<stdio.h> void?printLine()?????//這里定義的方法對嗎? { ???printf("**************\n");??? } extern?void?say(); 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(); ?}