Home > Back-end >  Why don't read files after the Spaces in the counting problem is a char (feeling) don't kn
Why don't read files after the Spaces in the counting problem is a char (feeling) don't kn

Time:09-30

A used to calculate the TXT file number of various types of small small programs,

#include
#include
#include
#include
/* run this program using the console pauser or add your own getch, system (" pause ") or the input loop */
using namespace std;

Const int SIZE=100;
Int main (int arg c, char * * argv) {
Cout & lt; <"Enter the file for analysis.";
Char ch;
Int whitespace=0;
Int who=0;
Int chars=0;
Int punct=0;
Int others=0;

Char filename [SIZE];
Cin. Getline (filename, SIZE);
Ifstream inFile.
InFile. Open (filename);
if(! InFile. Is_open ())
Cout & lt; <"The Error404!" InFile & gt;> Ch;
While (inFile. Good ())//test for sentinel
{
If (isalpha (ch))//is it an alphabetic character?
Chars++;
Else if (isspace (ch))//is it a whitespace character?
Whitespace++;
Else if (isdigit (ch))//is it a digit?
Digits++;
Else if (ispunct (ch))//is it punctuation?
Punct++;
The else
Others++;
InFile & gt;> Ch;//get the next character
}
If (inFile. Eof ())
Cout & lt; <"Read over!" Cout & lt; InFile. Close ();
return 0;
}

CodePudding user response:

May be skipped, flow operator have to skip the function of the blank characters

CodePudding user response:

Crab crab crab crab solved!
  • Related