let me revise this. i need help closing the file, not opening it. when i try to run this i get an error message saying it expected a constructor or destructor before the "." token on the line that has inputFile.close(). what does that mean? how do i properly close this file?
Code:#include <iomanip> #include <iostream> #include <fstream> #include <ctype.h> using namespace std; bool myIsAlpha( char ch ); bool myIsDigit( char ch ); bool myIsUpper( char ch ); int countPunct = 0, countAlpha = 0, countUpper = 0, countLower = 0, countChar = 0, countDigit = 0, countSpace = 0, countWhite = 0; char ch; int main() { ifstream inputFile; //Open the input file. If it fails to open, display an error message and //end the program inputFile.open( "input.txt" ); if( inputFile.fail() ) { cout << "input.txt failed to open"; exit( -1 ); } if(ispunct(ch)) { countPunct++; } else if(myIsAlpha(ch)) { countAlpha++; } else if (myIsDigit(ch)) { countDigit++; } else if (myIsUpper(ch)) { countUpper++; } else if (islower(ch)) { countLower++; } else if (isspace(ch)) { countWhite++; } } //Close the input file inputFile.close(); return 0; }



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.