Mail Archives: djgpp/1997/10/22/11:19:32
From: | "Ingo Ruhnke" <ruhnke AT owl-online DOT de>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Need some help ! When I try to read a file it says SIGSEGV error
|
Date: | 19 Oct 1997 19:22:02 GMT
|
Organization: | Telemedia News Server
|
Lines: | 46
|
Message-ID: | <01bcdcc9$456adde0$0200a8c0@ingo>
|
References: | <xhoul04 DOT 25 DOT 00107906 AT vse DOT cz>
|
NNTP-Posting-Host: | gtso-m71-251.pool.mediaways.net
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Houska Ludek - IN <xhoul04 AT vse DOT cz> schrieb im Beitrag
> Recently I downloaded the DJGPP. When I try to read simple file it
says
> only SIGSEGV error. ( I use fscanf( file, "%d", &number ) and the file
looks
> like this :
> 3 1 2 2 2 2
>
> - only numbers, the program runs through the cycle( read one number ) two
> times, and then it crashes. The value from the file doesn't even get into
> the variable.
Did you opened the file correctly? If not try this:
#include <stdio.h>
int main()
{
FILE *in;
int number;
if ((in = fopen("num.txt", "r")) == NULL) {
printf("file not found\n");
return 1;
}
while(fscanf(in, "%d", &number) == 1) {
printf("%d ", number);
}
putchar('\n');
fclose(in);
return 0;
}
This worked fine on my system
Ingo
--
Ingo Ruhnke
eMail: ruhnke AT owl-online DOT de
www: http://www.geocities/SiliconValley/Horizon/2159
- Raw text -