I have written the following code
On line number 19, Input_file>>line ;
this only take first word of file, how do I proceed??
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#include<iostream>
#include<locale>
#include<fstream>
#include<string>
using namespace std;
int main()
{
ifstream Input_file;
string line;
int counter=0;
char c;
locale LOC;
Input_file.open("example.txt");
if(Input_file.fail())
{
cout<<"File is not open";
}
Input_file>>line;
for(string::size_type i=0;i<line.length();i++)
{
c=line[i];
if(isspace(c,LOC))counter++;
}
cout<<counter;
return 0;
}
|
Last edited on
Thanks , it worked...
but if I want to measure black spaces from next line??
There is are several line inside that text file...
ohhh thanks , it worked...
:) :) :)