Re: strange problem with ptr in linked list
- From: Pascal Bourguignon <pjb@xxxxxxxxxxxxxxxxx>
- Date: Fri, 17 Nov 2006 13:40:29 +0100
atv <alef@xxxxxxxxx> writes:
I am setting upon initialization of program the head and tail pointers
both to NULL.
then, in a function where i add nodes to it, i check with:
database *search=head; /* set to beginning */
while(search!=NULL)
but it returns true upon first calling the function.
what is happening here?
any idea's would be most welcome
So, you are doing:
% cd /tmp/ ; cat a.c
#include <stdio.h>
typedef int database;
int main(void){
database* head=NULL;
database* tail=NULL;
database* search=head;
printf("start\n");
while(search!=NULL){
printf("search is not null\n");
}
printf("fini\n");
return(0);
}
% gcc a.c -o a ; ./a
start
fini
%
and you don't get the same result?
--
__Pascal Bourguignon__ http://www.informatimago.com/
HEALTH WARNING: Care should be taken when lifting this product,
since its mass, and thus its weight, is dependent on its velocity
relative to the user.
.
- Follow-Ups:
- References:
- strange problem with ptr in linked list
- From: atv
- strange problem with ptr in linked list
- Prev by Date: Re: to select() or poll() ??
- Next by Date: Re: System resource information on HP-UX
- Previous by thread: strange problem with ptr in linked list
- Next by thread: Re: strange problem with ptr in linked list
- Index(es):