Monday 6 January 2020

c++ - In C, importance and usage of extern storage class specifier








Actually I want to know the importance of extern.



First I wrote some code :



file1.h



extern int i;


file2.c




#include
#include "file1.h"
int i=20;
int main()
{
printf("%d",i);
return 0;
}



Now my question is that: what is the use of extern variable when I have to define the i in file2.c, declaring in file1.h is in which way useful to me .



sudhanshu

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...