Mail Archives: djgpp/1998/03/26/05:33:48
>void swap_points(POINTPTR a, POINTPTR b) //Assign pointer types to a & b
>{
> POINTPTR temp; //Create a temporary address holder
> temp->x = a->x; //Shift point a to temp
> temp->y = a->y;
You can't do this: temp doesn't point to anything, or better it points to
some invalid area. While TC doesnt' complain about this, DJGPP detects an
access to invalid memory and stops the program.
Under TC you were lucky it didn't touch some important areas of memory,
leading to some not obvious malfunction.
If you do like this the space is allocated on the stack, and your program
shouldn't crash anymore: (at least in this place :-)
POINT temp; //Create a temporary address holder
temp.x = a->x; //Shift point a to temp
temp.y = a->y;
// and so on...
BTW. the ANSI standard for C requires main to return int and not void.
ciao
Giacomo
- Raw text -