how to initialize variables in one file through all other files

HELLO FRENZ would u help me by telling how can i initialize and access variables declared in one file through all other files in VC++. If needed then plz explain me by giving code.please helpp me as it is very urgent.

thank-you

Comments

: HELLO FRENZ : would u help me by telling how can i initialize and access variables declared in one file through all other files in VC++. If needed then plz explain me by giving code.please helpp me as it is very urgent.: : thank-you: [blue]Your explanation of a problem is not quite clear, but if you are talking about the global variables then put them in one file:[code]// GLOBALS.CPPint glb_iValue;char glb_strPath [256];// ^^^ whatever more here...

// Put a function to init variables:void InitGlobals (){ // Set them up here whatever way you need... // load them from file... etc. glb_iValue = 4; strcpy (glb_strPath, "whatever...");}

// Put a function to release your variables:void DoneWithGlobals (){ // Put code here to release your global objects...}[/code]Then make a header file to use in all other files:[code]// GLOBALS.Hextern int glb_iValue;extern char glb_strPath [256];// ^^^ exact replica of vars, just put the 'extern' before them...

// Prototypes of functions inside GLOBALS.CPPvoid InitGlobals ();void DoneWithGlobals ();[/code]Now, include GLOBALS.H into every other CPP file in your project and call [b]InitGlobals()[/b] when you begin your program and call [b]DoneWithGlobals()[/b] when you end it:[code]#include "globals.h"