Hello,
I am having a problem reading from a text file using fstream on the LCDK with bios 6.35.04.50. Two approaches are shown below:
int data[2];
Approach A:
FILE *fp = fopen("C:\\filename.txt","r"); // read mode
fscanf(fp,"%d %d",&data[0],&data[1]);
printf("data = %d, %d\n",data[0],data[1]);
fclose(fp);
Approach B:
std::fstream ifs("C:\\filename.txt", std::ios::in);
ifs >> data[0];
ifs >> data[1];
std::cout << "data = " << data[0] << ' ' << data[1] << std::endl;
ifs.close();
Approach A works fine. Using Approach A and Approach B (in succession) works fine. Using Approach B alone produces no output to console.
All necessary header files have been included.
Any help is greatly appreciated. Thank you.