c++ - Why am I getting a segmentation fault? -
I am trying to compile a simple Hello World function in C ++, after compiling it, Run and get "segmentation fault" Can anyone put some light on it?
I am compiling it using the Linux Command Line using the following command:
G ++ hello.cpp
The program itself looks fine, I think your compilation environment has some fun That is happening due to the Sigfault.
Your best bet is to run it in Debugger (GDB) - it will tell you that it is crashing, which will help you to understand what is the problem.
To do this, compile it like this:
G ++ -GO hello.cpp
Then run gdb:
gdb hello
and at gdb prompt
run
To run the program when it crashes, type
bt
which will give you a stacktrack that will hope - you know What will happen is going on.
Comments
Post a Comment