| | |
Global Variables
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Oct 2005
Posts: 27
Reputation:
Solved Threads: 0
Hello everyone,
I hope I can write this question clearly. Anyway, it is about global variables. I have several files in my C++ project. One of which is main.cpp. This file comtains my main() function. I have a few other files in my project. They are server.cpp, server.h, strings.h, includes.h and functions.h. My main.cpp function #includes the includes.h file which includes strings.h and functions.h.
My main() function fills a variable located win strings.h called sysName[32]. My main() function then calls a function in server.cpp. Becuase I delcared a prototype in server.h, it works. Now, my function in server.cpp cannot read my sysName variable even though #include "includes.h" is located in its header file.
Why can't I access this variable. I think all the #includes are correct?
I have been searching google and have been working on this for like 2 hours now with no luck.
Thanks for any help.
I hope I can write this question clearly. Anyway, it is about global variables. I have several files in my C++ project. One of which is main.cpp. This file comtains my main() function. I have a few other files in my project. They are server.cpp, server.h, strings.h, includes.h and functions.h. My main.cpp function #includes the includes.h file which includes strings.h and functions.h.
My main() function fills a variable located win strings.h called sysName[32]. My main() function then calls a function in server.cpp. Becuase I delcared a prototype in server.h, it works. Now, my function in server.cpp cannot read my sysName variable even though #include "includes.h" is located in its header file.
Why can't I access this variable. I think all the #includes are correct?
I have been searching google and have been working on this for like 2 hours now with no luck.
Thanks for any help.
since you didn't post any code we can only guess. sysName is apparently NOT declared in any of the header files that are included in server.cpp. user the extern keyword like below.
// includes.h
extern char sysName[32];![]() |
Similar Threads
- Username/Password help, OrderBy help, and Global variables (Visual Basic 4 / 5 / 6)
- C- Syntax to allocate Global variables to consecutive memory locations (C)
- Global Variables in Functions (Python)
- Global Variables not so 'global' (Visual Basic 4 / 5 / 6)
- Global v/s Public (Visual Basic 4 / 5 / 6)
- Global Variables help (C)
Other Threads in the C++ Forum
- Previous Thread: Trouble getting code to compile
- Next Thread: How do I delete an instance of an Array?
Views: 3502 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






