ccplusplus.com
Learn C, C++ Concepts
Sunday, December 25, 2011
variable definition vs declaration in c example
/*********************************************************************** * File : definition-vs-declaration.c * Author : Saurabh Gupta * Desc : Variable Definition vs Declaration in C * Source : http://ccplusplus.com/p/c.html * Created : PM 04:56 25 December 2011 * Note : This file requires two more files. file2.c and file3.c ************************************************************************/ #include <stdio.h> void next (void); void next1 (void); int a1 = 0; int main () { printf ("*** Definition vs Declaration ***\n"); a1 = 2; printf ("a1 = %d\n", a1); // a1 = 2 next (); next1 (); printf ("a1 = %d\n", a1); // a1 = 3 return 0; } /* * OUTPUT * [sgupta@rhel6x64 definition-vs-declaration]$ gcc -c file2.c [sgupta@rhel6x64 definition-vs-declaration]$ gcc -c file3.c [sgupta@rhel6x64 definition-vs-declaration]$ gcc -c definition-vs-declaration.c [sgupta@rhel6x64 definition-vs-declaration]$ gcc -o definition-vs-declaration definition-vs-declaration.o file2.o file3.o [sgupta@rhel6x64 definition-vs-declaration]$ ./definition-vs-declaration *** Definition vs Declaration *** a1 = 2 a1 = 13, b1 = 19.200001 a1 = 13 [sgupta@rhel6x64 definition-vs-declaration]$ */
Download Other Files:
1.
file2.c
2.
file3.c
See Also:
C language Tricky Concepts and Sample Codes
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment