Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- string text;
- int charCount=0, lineCount=0, wordCount=0, num=0;
- ifstream file("Ass73.txt");
- while(getline(file,text))
- {
- cout<<text<<endl;
- lineCount++;
- wordCount+=1; //first word of the line
- for(int c=0;c<text.length();c++)if(text[c]==' '&&text[c+1]!=' '&&text[c+1]!=NULL)wordCount+=1;
- charCount+=text.length();
- }
- cout<<"\nNumber of characters: "<<charCount<<endl;
- cout<<"Number of words: "<<wordCount<<endl;
- cout<<"Number of lines: "<<lineCount;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement