In the example program, I want to read from two files.
The first files works fine but I do not get an output from the second one. I am using Visual C++.
thanks for your help,
dwygal
Code:#include<iostream> #include<fstream> using namespace std; int main() { ifstream inData; //declaring file variable inData.open("C:\\Documents and Settings\\Wygal\\Desktop\\textFiles\\groc-inv.txt"); char ch; //declaring character variable while(!inData.eof()) //getting the multiple line file { inData.get(ch); cout << ch; } cout << endl; inData.close(); //closing first file /*_____________________________OPEN SECOND FILE_____________________________________*/ inData.open("C:\\Documents and Settings\\Wygal\\Desktop\\textFiles\\grocery.txt"); inData >> ch; //TRYING TO GET A CHARACTER cout << ch << endl; //TRYING TO PRINT CHARACTER //THIS ACTION IN NOT WORKING return 0; }



LinkBack URL
About LinkBacks


