logo

Declaration vs. Definition of a variable in C

#include <stdio.h> #include <stdlib.h> // Declaration // - what you need when using the variable // (name + type) // Definition // - what you need when executing the program // (address + space + Declaration) extern int x; int y = 5; int main(int argc, char* argv[]) { x = 20; printf("x = %d\n", x); printf("y = %d\n", y); return 0; }