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

#include & lt; Iostream & gt; using namespace std; Int main () {cout & lt; & Lt; "Hello world!" & Lt; & Lt; Endl; Return 0; }

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

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -