Re: strange problem with ptr in linked list



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.
.