I have made two files in c i.e. file1.c file2.c. In file1.c I wrote
#include< stdio.h >
int s=10;
void main()
{
printf("This is file 1");
}
In file2.c
include < stdio.h >
extern int s;
void main() {
printf("%d",s);
}
When I compiled file2.c in ubuntu terminal I got undefined referenced to s error.
How can I resolve this error?
main()ALWAYS returnsint, notvoid2) there can be only 1 function namedmain()3) have one of those files (the one that finally contains themain()function, call the (new function name) in the second file AND provide a prototype for that (new function name) in the file that contains themain()function.svariable, HOWEVER, the linker will complain,