Hi all,
Im getting an exception in the middle of reading a file and here is my code
This code itself is in a loop and so, Im using the sleep function for some delay for my custom processing.
Please help me out with this. I have no clue whats the problem.
Thanks a lot.
SC
Im getting an exception in the middle of reading a file and here is my code
Code:
std::ifstream inf; const int bufSize=1024; char tbuffer[bufSize]; std::string filex = path; // may be C:\test.txt const char* stx = &filex[0]; inf.open(stx,ios_base::in|std::ios::binary); if(!inf.good()) { inf.clear(); inf.close(); std::cout<<std::endl<<"Cant open file "<<std::endl; exit(1); } inf.exceptions ( ifstream::eofbit | ifstream::failbit | ifstream::badbit ); try { while(inf.good()) { inf.getline(tbuffer,bufSize); cout<<endl<<tbuffer<<endl; ::Sleep(50); } inf.clear(); inf.close(); delete inf; } catch(ifstream::failure e) { cout<<endl<<"exception-->file exception"<<e.what()<<endl; exit(1); }
Please help me out with this. I have no clue whats the problem.
Thanks a lot.
SC
Comment