+ 1

Need help guys....if we declare a variable in any structure can we use those variables inside any fuction???

c language

4th Sep 2017, 2:12 AM
BuckyAlita
BuckyAlita - avatar
5 ответов
+ 1
you have to declare it globally so that you can use it anywhere part of the program.
4th Sep 2017, 4:17 AM
geniuS
+ 2
The safer and cleaner way is to pass it as a parameter of the function, but you'll have to either pass its address or return it so that what you changed during the function call can be saved
4th Sep 2017, 7:19 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
did you mean C# or c++? because c isnt on this app
4th Sep 2017, 2:19 AM
Enzo
Enzo - avatar
+ 1
i guess it doesnt really matter which one as long as the struct is accessible and that what your trying to access in the struct is public(default in c++) then sure you can access it from any function
4th Sep 2017, 2:26 AM
Enzo
Enzo - avatar
+ 1
No you cannot delcare anywhere and use it anywhere.
4th Sep 2017, 4:16 AM
geniuS