Take Input And Count The Word's Of .txt File
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main() {
string g;
int Length;
fstream file;
file.open("GaMeS.txt", ios::out);
if (!file)
{
cout << "File Does Not Exist";
}
else {
cout << "File Is Create Successfully
" << endl;
getline(cin, g);
file << g;
Length = g.length();
file <<
endl;
getline(cin, g);
file << g;
Length = Length + g.length();
file <<
endl;
getline(cin, g);
Length = Length + g.length();
file << g;
file <<
endl;
cout <<
endl;
file.close();
cout << "Total Characters Are = " << Length << endl;
}
system("pause");
}
Comments
Post a Comment