Hi in my program for some reason when I assign somthing to a certain pointer my program segfaults. I have tested this by calling exit(0) just before the assignment and it exits fine, just after the line and it segfaults. I have tried making a variable with a different name that is of the same type, and assigning that and it works fine.
So my question is, when could setting a pointer to point at somthing directly cause a segfault?
Ovbiously if I assigned it wrong and then tried to use what it pointed to it could segfault but actualy making it point at somthing is causing the problem!
This crashes:
but this doesn'tCode:struct Slevel *level;struct Slevel *test_level; /* Load the map if needed*/ if (level == NULL) { test_level = load_level("levels/test.txt"); level = test_level; exit(0); }
My code is an absolute mess at the moment, so if you could tell me an example that just setting a pointer could cause a segfault it would get me started as to what to look for. ThanksCode:struct Slevel *level;struct Slevel *test_level; /* Load the map if needed*/ if (level == NULL) { test_level = load_level("levels/test.txt"); exit(0); level = test_level; }



LinkBack URL
About LinkBacks


