hi all,
heres a nuebie question for ya.. I'm trying to create infinite loop that continually assigns the results of some called functions to various variables, but i'm having a problem with re-assignment of the variables on the second loop? Basically I get a core dump!
Could anyone point me in the correct direction. Here is some pesudo code to show what i mean am doing...
main() {
int sentinal;
char *GetValue;
char * value;
sentinal = 1;
while (sentinal !=0) {
value = GetValue(); /* returns a char* */
printf("Value is %s\n", value);
sleep(10);
}
}
The loop does work, but core dumps on the second itteration. The problem is with the re-assignment of 'value'. How can i do this safely?
I have tried combos of malloc, calloc, setting value to "" but still core dumps. I am compiling with gcc under FreeBSD unix..
Any help appreciated.
Regards,
JayB0t
"Always know what you say, but don't always say what you know!"
heres a nuebie question for ya.. I'm trying to create infinite loop that continually assigns the results of some called functions to various variables, but i'm having a problem with re-assignment of the variables on the second loop? Basically I get a core dump!
Could anyone point me in the correct direction. Here is some pesudo code to show what i mean am doing...
main() {
int sentinal;
char *GetValue;
char * value;
sentinal = 1;
while (sentinal !=0) {
value = GetValue(); /* returns a char* */
printf("Value is %s\n", value);
sleep(10);
}
}
The loop does work, but core dumps on the second itteration. The problem is with the re-assignment of 'value'. How can i do this safely?
I have tried combos of malloc, calloc, setting value to "" but still core dumps. I am compiling with gcc under FreeBSD unix..
Any help appreciated.
Regards,
JayB0t
"Always know what you say, but don't always say what you know!"