![]() |
Global Variables, anyone?
So, uh.... how do you use global varibles in C? I am a C++ vet, and this primative programming language and rigid syntax requirements are VERY frustrating!!! :mad:
Thanx for any help you offer |
Re: Global Variables, anyone?
I believe that it's either including a header, or using the extern keyword.
I'm the other end of the spectrum: I'm a VB pro, not used to the power and details of C. There's a thread on extern (and probably globals, too). |
Re: Global Variables, anyone?
The easiest way (in my opinion) is to use the extern keyword. You can do this using two methods:
Code:
main.c (or another file) |
Re: Global Variables, anyone?
technically, any variable declared at the beginning of a file and not within a function is global variable, but only in file-level scope. To make it span across multiple files, declare it in the other files as well but add "extern" before the other definition (remember, exactly ONE definition of the variable should not have an "extern" in front of it)
|
| All times are GMT -5. The time now is 22:23. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi