Question with "extern" in C

Posted by why on Stack Overflow See other posts from Stack Overflow or by why
Published on 2010-12-28T02:48:05Z Indexed on 2010/12/28 2:54 UTC
Read the original article Hit count: 218

Filed under:
|

When programming, I would like to split one large file(which contains main function) to many small files, so there is one common case: functions in small files can modify the var from main file, so i think extern is very useful!

for instance:

in main.c

 extern int i = 100;

in small.c

extern int i;
fprintf(stdout, "var from main file: %d\n", i);

I just want to know is my understanding right?

© Stack Overflow or respective owner

Related posts about c

    Related posts about linux