S
ssantamariagarcia
I have found a problem while using a while statement and a linked list.
I had never met this matter before....and I am wondering that if you
have , please tell me what it is wrong.
I am traversing the linked list using a pointer to cycle through.
int Function(...){
node * p;
p=linkedlist; // p is a pointer to the list first node .
while (p!=NULL){
if(....){
// do something with p
}
printf("\nIf I place a printf here , the while loop woks out;
it doesn't if not);
p=p->siguiente;
}
}
The matter is that if the printf statement is removed, the loop break
and send a NULL exception message.
The printf can be placed after advancing linked list, it can be the
first statement of the loop.... even it can be before this function is
called , and all works right.
But not without it.
Any idea?
Thanks a lot, SONIA
I had never met this matter before....and I am wondering that if you
have , please tell me what it is wrong.
I am traversing the linked list using a pointer to cycle through.
int Function(...){
node * p;
p=linkedlist; // p is a pointer to the list first node .
while (p!=NULL){
if(....){
// do something with p
}
printf("\nIf I place a printf here , the while loop woks out;
it doesn't if not);
p=p->siguiente;
}
}
The matter is that if the printf statement is removed, the loop break
and send a NULL exception message.
The printf can be placed after advancing linked list, it can be the
first statement of the loop.... even it can be before this function is
called , and all works right.
But not without it.
Any idea?
Thanks a lot, SONIA