Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

globals in C

Status
Not open for further replies.

deb9

Programmer
Sep 21, 2005
8
0
0
US
Hi,

I have the following code

void (*somevector[20])(someptr *ptr);

void foo(someptr * ptr){...}

void somefunction() {
do something with somevector[0];
}

void otherfunction() {
somevector[0]=foo;
somefunction();
}

It keeps telling me in somefunction that somevector[0] is null, even if I initialize it in otherfunction. What is the problem? Isnt somevector global anyway?

Thanks

deb
 
Show us the code in somefunction.
There is a suspicious pointer to pointer (?) parameter someptr* ptr).
Yes, you have a global array of pointers to functions. Of course, you have an initialization of its 1st element...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top