I am having a litle trouble following everything but ..
1) What is the purpose of the tellg() / seekg() ?
2) The following type of construct will loop one too many times,
since eof() is not true until there is an actual attempt to read past EOF.
Change these to:Code:while(!numFile.eof()) {//Loop through file with two numbers getline (letterFile,letterLine);
Code:while ( getline (numFile,numLine) ) {
3) After reading processing the first line in letterFile, it will never be successful
in opening the numFile a second time. To solve this problem, you should
desclare the stream object when you use it if possible.
4) If the second file contains numbers, why reading them in as strings ?Code:ifstream numFile(numFilename, ios::in); if (!numFile) { cerr << "Can't open input file " << numFilename << endl; exit(1); }
Code:int number1 , number2; while (numFile >> number1 >> number2) {
5) Why mix C and C++ outputs so much (printf , ifstream , cerr). Since you are
coding in C++, I would stick to the C++ I/O, unless there is a specific reason
not to.
6) what type is letter ?




Reply With Quote
