N
noridotjabi
I know that if I want a variable to be global I can define it as such:
....
int var;
int main() {
....
return 0;
}
This way I can access it in all of my functions without passing it as
an argument. I am unsure, however, as to wheater it is possible to do
this with seperate source files. For instance can I have:
/* one */
#include <stdio.h>
int num;
int main() {
chnum();
printf("Num is %d\n", num);
return 0;
}
/* two */
#include <stdio.h>
void chnum() {
num = 7;
return;
}
Is this possible? Thanks in advanced.
Nori
....
int var;
int main() {
....
return 0;
}
This way I can access it in all of my functions without passing it as
an argument. I am unsure, however, as to wheater it is possible to do
this with seperate source files. For instance can I have:
/* one */
#include <stdio.h>
int num;
int main() {
chnum();
printf("Num is %d\n", num);
return 0;
}
/* two */
#include <stdio.h>
void chnum() {
num = 7;
return;
}
Is this possible? Thanks in advanced.
Nori