Hi,
I have been using C++ for the past 6 months and always had a problem of using the same IFSTREAM variable to read multiple files.
Please help with problem...I searched a lot in google but couldnt find the solution...
I asked a few friends and they gave me an option of using an array of File Pointers instead of reading...which is a waste of memory I feel. I want to know Why am not able to use this way...what am I doing wrong...
Hoping for solutions...
will be great if solved...
Thank You in advance....
Regards,
Digital Don
I have been using C++ for the past 6 months and always had a problem of using the same IFSTREAM variable to read multiple files.
Code:
do//Repeat while quit not entered { ipf.clear(); cout<<"\nGive file name (Q for Quit):"; cin>>ipf; ipfilename.open(ipf.c_str(),ifstream::in); //Not able to reuse the above pointer with new filename (ipf) if(ipfilename.fail()) . . . else { while(!ipfilename.eof()) { getline(ipfilename,tempread); ... } //ipfilename.clear();//Clearing the file pointer –Didn’t work ipfilename.close();//Closing the file } }while(!(ipf=="Q" || ipf=="quit" || ipf=="Quit" || ipf=="q"));
I asked a few friends and they gave me an option of using an array of File Pointers instead of reading...which is a waste of memory I feel. I want to know Why am not able to use this way...what am I doing wrong...
Hoping for solutions...
will be great if solved...
Thank You in advance....
Regards,
Digital Don
Comment