0

Is there any way to detect where the location of a segmentation fault is in a c program?

30th Oct 2017, 2:48 PM
Gokul Krishna
Gokul Krishna - avatar
4 Respostas
+ 6
Your compiler will normally state where the line of error is (and the function). Then you can use a debugger to find what is causing that particular line of code to fail.
30th Oct 2017, 2:54 PM
Wen Qin
Wen Qin - avatar
0
what is the function of program ?? http://www.geeksforgeeks.org/core-dump-segmentation-fault-c-cpp/ A common run-time error for Cprograms by beginners is a "segmentation violation" or "segmentation fault." When you run your program and the system reports a "segmentation violation," it means your program has attempted to access an area of memory that it is not allowed to access.
30th Oct 2017, 2:55 PM
Nanda Balakrishnan
0
in code blocks it just crashes out...
30th Oct 2017, 2:57 PM
Gokul Krishna
Gokul Krishna - avatar
0
The easiest way to track it down is lots of cout statements so you know how far you get. You have something you didn't put a value in. More than likely an argument to a function or local function variables. Depending on code, put one cout at the start of each function and after each loop. This should get you to the right place that the problem is happening. Next, put one after each statement to find the last one that worked. The following statement is the problem.
30th Oct 2017, 3:08 PM
John Wells
John Wells - avatar