GCC Compiling (Linux), "Segmentation Fault"
I'm trying to write a program to solve the quadratic exuation and find the vertex. I managed to get it to compile in both the GCC and the G++ (It's written in C), but I can't get it to actually run. Right after entering the first number, it gets a segmentation fault.
Konsole: Code:
[neil@localhost ~]$ gcc '/home/neil/Desktop/calc.c' -o '/home/neil/Desktop/calc.exe' -lm Code:
#include <stdio.h> |
A segmentation fault means "Invalid memory reference". Your program is given a certain range of memory to play with, and if you attempt to access memory outside of that range the kernel will stop it before it does damage.
To fix it, you should find your programming error =) EDIT: Looking at the code, I found the problem within 5 seconds. scanf() needs the address of where to store the data. You should be using like &ax instead of ax. |
You really want to become familiar with gdb and ddd;
they can help you locate such problems (usually). |
All times are GMT -5. The time now is 05:18 AM. |