The C language Storage types include extern, auto, static, and register.
External variables are defined outside the function, and all references to external variables through the same name (even if such references come from different functions compiled separately ), in fact, all references to the same external variable are referenced (this property is called an external link in the C standard ). Therefore, external variables can be accessed globally.
GetChar. c:
# Include
# Include
Extern char str []; // do not declare it in the header file
Int index_str = 0;
Char getChar (){
Return str [index_str ++];
}
GetStr. c:
# Include
# Include
Char str [255];
/* Get the testfile string */
Void getStr (char * filename ){
Int index = 0;
FILE * fp;
If (fp = fopen (filename, "r") = NULL ){
Printf ("open test_file fail !!! \ N ");
Exit (1 );
}
While (str [index ++] = getc (fp ))! = EOF );
Str [index] = '\ 0';/* end sign */
Fclose (fp );
}
Http://blog.csdn.net/pipisorry/article/details/25346379