getting segmentation fault error
Friends, I am running a c++ program on linux and it is showing segmentation fault error but same program works fine in windows. What may be the reason as I am new in programming on linux.
|
A segmentation violation occurs when a program tries to access memory which is not allocated for use by the program. This usually results from a program trying to use some object or pointer which has not been properly initialised, or has been corrupted somehow.
In short, your program has a bug. You must provide more details if you would like a more precise diagnosis. |
Hello!
Try following steps: 1) Compile your program with `-g' option: Code:
g++ -g <your_program>.cpp 2a) in the GDB prompt type `run': Code:
(gdb) run <put_program_options_here> Code:
Program received signal SIGSEGV, Segmentation fault. 3) Another cool program is `valgrind'. Install it! Usage is very simple: `valgrind a.out' or `valgrind --leak-check=full a.out' 4) Post your code here. Bye. |
All times are GMT -5. The time now is 02:00 AM. |