Click to See Complete Forum and Search --> : gcc help
Riley
06-05-2002, 11:22 AM
It tells me there is a segmentation fault...
What does that mean? The last two lines of my code are printf()s and they print to the screen and the fault isn't until after them. The only thing after them is main's closing brace... what to do?
debiandude
06-05-2002, 11:40 AM
Your probably overruning a buffer or something and then printing the string or whatever at the end. Post the code and we'll see where you are going wrong.
dchidelf
06-07-2002, 09:06 PM
A segmentation fault is caused when your program is trying to access memory that it should not. (Memory in a different segment)
The instructions of a program are located in a different segment than the data. This is meant to protect the instructions from being modified by the program.
Whenever a program tries to access memory in a segement that is protected, a segmentation fault occurs.
If your program is making it past the printf statements without the fault it is very likely that somewhere in you code you have created a reference to a position in memory that is in another segment (probably address 0x00000... ) and, as the destructors are making their rounds cleaning up memory before the program terminates, the cleanup process tries to free that memory... SEG FAULT!
Hope that's helpful.
If you post your code we could look at it.