-
October 3rd, 2004, 05:26 AM
#1
How to access Global variables and functions
How can I access global variables and function in my VC++ applications
Thankx in advance
-
October 3rd, 2004, 05:45 AM
#2
Re: How to access Global variables and functions
As long as the variable and function are not being declared as static in file scope, you need to declare them as extern in your calling file.
Code:
// Original file
int temp;
void foo(void);
// Calling file
extern int temp;
extern void foo(void);
void bar(void)
{
foo();
}
-
October 3rd, 2004, 08:44 AM
#3
Re: How to access Global variables and functions
Of course, shared header files are much better
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
October 3rd, 2004, 11:22 AM
#4
Re: How to access Global variables and functions
Originally Posted by Kheun
As long as the variable and function are not being declared as static in file scope, you need to declare them as extern in your calling file.
Code:
// Original file
int temp;
void foo(void);
// Calling file
extern int temp;
extern void foo(void);
void bar(void)
{
foo();
}
Thankx it works !!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|