Should I use global variables or passing the variable to other functions?
I do need a variable to all the program, now, I did hear that using global-variables isn't a nice thing, now I think in some case's is better to use global-variables instead passing them trough all the functions, look:
Or should I make in this way:Code:#include <stdio.h> #include <stdlib.h> //my global variable char name[100]; [...] int main() { //here I use my global var.. [....]
Thanks for the helpCode:#include <stdio.h> #include <stdlib.h> void foo(char name[], int Blah, int Bloh); int main(void) { char name[100]; //here isn't global [...] foo(name,myNum1,myNum2); [...] return 0; }![]()



LinkBack URL
About LinkBacks



