I'm confused how to use #define, or if this is even what I want to be using.
I have a header file:
#define var 3;
int foo();
...(etc)
As well as two similarly structured files outside of it:
#include "header.h"
int main(int argc, char **argv){
printf("%i", var);
}
Am I wrong in thinking that I can use the var from the header in C files which include the header?
This is actually a part of homework, and I'm not permitted to change the header file. If I can't use it like this, is there some way to use the variable outside the file other than an accessor function?
#define var 3;is horrible, horrible C (especially that semicolon on the end). If this is the code you were provided, you should complain to the instructor...#define var 3;Omit the ';';after3should not be there.