hi,
can somebody please tell me what would be the problem that it couldn't open the file? i compiled it in dev c++ and it gives me no error. the file 512.dat is in the same directory.
#include<iostream>
#include<fstream>
#include<stdlib.h>
#include<stdio.h>
const int sc = 768;
int main()
{
int IF[sc];
int DEF[sc];
FILE *re1;
re1 = fopen("512.dat","r");
if(!re1)
{
// file couldn't be opened
cerr << "Error: file could not be opened" << endl;
}
for(int i=0;i<sc;i++)
{
int j,k;
fscanf(re1,"%d %d\n",&j,&k);
IF[i]=j;
DEF[i]=k;
}
fclose(re1);
for(int i=0;i<sc;i++)
{
cout<<"IF="<<IF[i]<<" "<<"DEF="<<DEF[i]<<endl;
}
system("PAUSE");
return 0;
}
thank you.