views:

50

answers:

1

Hi this a continuation of a previous question I asked however I wasn't registered then and thus cannot edit the question. Anyways I have a struct

typedef struct
{
 char input[100][100];
 int count;
 char name;
 int startTime;
}INPUT;

extern INPUT *global;

this is within the header file. A stackoverflow member suggested that in my source file i use

INPUT global_[N], *global = global_;

to declare and initialise it which worked fine(as in I was able to store and print information out of the struct from within that method) however when I go to use the variable in other parts of my code it seems that the variable is out of scope?

I declare and use the variable global_ in a method called readFile and i'm trying to access the same information in main via *global.

Can this be done?
Thanks
Chee

+1  A: 
extern INPUT *global;

This declares a global variable named global.

INPUT global_[N], *global = global_;

This defines an array global_ and a variable global. Depending on where this definition occurs (at function scope, or in a namespace, a class, or a function), global might or might not define the same object that's referred to by the declaration of global.

sbi