Original Post
Okay i though i understood pointers pretty well, but i guess i don''t, could someone please tell me why this program doesn''t work...
#include <stdio.h>
struct Test {
int a;
struct Test *next;
};
void GoHere( struct Test *ptr )
{
struct Test *newPtr = NULL;
newPtr = (struct Test *)calloc( 1, sizeof(struct Test) );
newPtr->a = 5;
newPtr->next = NULL;
ptr = newPtr;
printf( "looky - %d\n", ptr->a );
}
int main()
{
struct Test *first = NULL;
GoHere( first );
---> printf( "looky - %d\n", first->a );
return 0;
}
When it gets to the part with the arrow, why doesn''t it display 5, instead it just crashes and I don''t understand why. After GoHere is exectured first is supposed to point to newPtr, but it doesn''t
This is driving me mad....