c++ - Odd fstream issue -
i've got odd error programs i've written no longer reading files they're referenced if they're in same directory. tried old programs i've written , tested , haven't touched months yet return error message. wrote simple program test it:
#include <iostream> #include <fstream> using namespace std; int main() { fstream openfile; int num, cnt=0; openfile.open("data.dat"); if (!openfile) { cout << "error opening file" << endl; } else { cout << "i'm open!" << endl; while(openfile >> num) cout << num << endl; cnt++; } cout << cnt << endl; system("pause"); return(0); }
information on file:
1 2 5 66 9 4 2
this returns error message , cnt @ 0. file located in exact same directory executable. causing this? there issue program?
Comments
Post a Comment