[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: problems with gcc and fopen() in debian 2.2



Andreas Maresch wrote:

Hello!

I am (re)starting in programming c (I have learned it a while ago under
dos).
Yesterday, I wrote a simple program.
When compiled with gcc -o test test.c, no errors or warnings occured.

But when I try to run, it terminates with "Segmentation fault".
So, with the help of ddd (real nice tool ;-D ) I was able to locate the
problem: fopen().

ddd reported a seg fault on the following line:

infile=fopen("dir.dat", "r");

The "dir.dat" exists (in the same directory), and infile was deklared with:
FILE *infile;

My gcc-version is 2.95.

It's best to give the complete program and even better if you can give the shortest possible program that still gives the error.

Paul Scott



Reply to: