Hello guys I'm getting a segmentation fault when running a simple hello would program in C++ any help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hello guys I'm getting a segmentation fault when running a simple hello would program in C++ any help

I'm using g++ to compile though and I'm getting a [1] 12429 segmentation fault ./a.out whenever i try to run the program

4th Aug 2019, 6:38 PM
Primidac
Primidac - avatar
3 Answers
+ 7
Primidac, Segmentation fault generally occurs because of these reasons like 1) Array out of bound:- means you are reading or writing an element which is out of bound of the array like int arr[100]; for (int i = 0; i <= 100 ; i++) arr[i] = i; So in this case at reading or assigning variable at 100 will cause program crash and generate segment fault 2)illegal memory access is one of the another reason where you are reading or writing element in an memory location which is not present in the condition. So if you link the code with the thread then anyone can help you in better ways.
4th Aug 2019, 6:47 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 6
Primidac if that's the case then may be some error in compilation environment reinstall the codeblocks or debugg by gdb debugger and follow the top answer of this link it may help you out https://stackoverflow.com/questions/2131646/why-am-i-getting-a-segmentation-fault
4th Aug 2019, 7:00 PM
GAWEN STEASY
GAWEN STEASY - avatar
0
the code is just a simple c++ hello world program
4th Aug 2019, 6:49 PM
Primidac
Primidac - avatar