My Main file
The file where I store global variables
The 2 files compile well but nothing is printed as I want.
CodePudding user response:
The problem is your function sum(int a, int b)
has argument names that shadow the global variables you are trying to access. Also you need to call the sum()
function, not just declare it.
Try this instead:
#include <stdio.h>
extern int a;
extern int b;
void sum() {
printf("Sum is : %d", a b);
}
int main() {
sum();
}