pointer problems, help!

Dr. Richard Glass reg at pinet.aip.org
Sat Mar 23 05:12:15 AEST 1991


The answer is that your structure definition contains pointers
that do not have valid rvalues to de-reference (PPRL)
(pointers pointing to random locations).  The
value of these pointers are random memory.  In this case,
most likely to the same address do to your results.  On some systems,
a runtime error could be produced sometimes - other times - who knows.

The fix here is to either re-define the fields of the structure to be
arrays or allocate the various fields
ex: target_player.first_name = malloc(the_size_U_need_to_hold_name +1)

The bug here is equivalent to the following piece of code:

foo()
{
char *random_pointer;

strcpy(random_pointer,"Hello world");
}

Ricky Glass reg at pinet.aip.org



More information about the Comp.lang.c mailing list