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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -