i need the main body of this to execute, i figured a while loop but i have no idea what would go inside, i've never dealt with inputting files before. if i just run it without the while loop everything comes back as 0, obviously. i don't know what possible condition to use to make this run correctly.
Code:#include <iomanip> #include <iostream> #include <fstream> #include <ctype.h> using namespace std; bool myIsAlpha(char ch) { if((ch > 64 and ch < 91) or (ch > 96 and ch < 123)) return true; else return false; } bool myIsDigit( char ch ) { if (ch > 47 and ch < 58) return true; else return false; } bool myIsUpper( char ch ) { if (ch < 64 and ch > 91) return true; else return false; } 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; inputFile.open( "input.txt" ); if( inputFile.fail() ) { cout << "input.txt failed to open"; exit( -1 ); } while () { if(ispunct(ch)) { countPunct++; } if(myIsAlpha(ch)) { countAlpha++; } if (myIsDigit(ch)) { countDigit++; } if (myIsUpper(ch)) { countUpper++; } if (islower(ch)) { countLower++; } if (isspace(ch)) { countWhite++; } } //Close the input file inputFile.close(); cout<<"\n"<<countPunct<<"\n"<<countAlpha<<"\n"<<countDigit<<"\n"<<countUpper; return 0; }



LinkBack URL
About LinkBacks



