C Global Declaration
I have this small problem which i couldnt figure out.
i have a c program in which i have a function,say function1 which i call from the main thread. From this function which i mentioned above i pass some value to some other function,say function2 and do some operation there,say display the value. Note:i m not passing any value from main to function1.The value passed from function1 to function2 is declared in function1. i found this strange,maybe due to my lack of expertise, when i pass a single variable say int i, and display it in function2 it works fine but if the same is done with an array of int's it displays a junk value. But the above problem is solved if i declare the array of int's as global. I cant figure out why this happens, do give me some suggestions in this regard. |
Maybe a little code might help us :)
|
ok, so I'm sick, can't sleep, and bored, so I decided to write you a dumb little example of how things work.
Code:
#include <stdio.h> Code:
johnshaw@Quaqmire-OSX ~/test $ gcc -Wall -o test2 test2.c |
Thanks jtshaw,i think that has cleared my doubt
Thank u addy,sorry for not posting the code snippet anyways the problem is solved |
All times are GMT -5. The time now is 02:42 AM. |