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:
Code:
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);
}
but this doesn't
Code:
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;
}
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. Thanks