Wednesday, May 4, 2022

checking number of words in a text file

 #include<iostream>

#include<fstream>
using namespace std;
int main(){
    string word;
    int count=0;
    ifstream file;
    file.open("newfile1.txt");
    while (file>>word)
    {
        cout<<word<<endl;
    count++;
    }
    cout<<"\n words in total are "<<count<<endl;
    file.close();
    return 0;
}

No comments:

HackCache ’26: A 48-Hour Online Hackathon Open to Every Student

  Hackathons are often associated with computer science students, experienced developers, and teams that already know exactly what they are...

Popular Posts