On Tue, 6 Oct 1998, [ISO-8859-1] Torbjørn Kristoffersen wrote:
->I'm wondering how it is possible to read from a file looking like this:
->
->
->0001 1
->0002 0
->0003 0
->0004 1
->
->
->The program should read the file and understand 0001 as an integer and 1 or
->0 as an integer. The two numbers should be saved in variables such as a, b.
->
Try this and add the necessary error-checking code...
#include <stdio.h>
int main()
{
FILE* pInFile;
int a,b;
pInFile= fopen("in.data", "r");
while ( !feof(pInFile) )
fscanf(pInFile,"%d %d",&a,&b);
fclose(pInFile);
}
Regards,
Marin
"Knowledge is not a crime. Some of its applications are..."
- Unknown hacker