What is worng with my code.
I can reads all the lines all right but it doesn't return me the length
of lines.
It returns 0 for each line
#include <fstream>
#include <istream>
#include <iostream>
#include <ostream>
#include <string>
int main()
{
fstream in("example.txt ");
static string line;
int len = line.length();
while(getline(i n,line))
{
cout<< line <<'\n';
cout<<len<<endl ;
}
return 0;
}
I can reads all the lines all right but it doesn't return me the length
of lines.
It returns 0 for each line
#include <fstream>
#include <istream>
#include <iostream>
#include <ostream>
#include <string>
int main()
{
fstream in("example.txt ");
static string line;
int len = line.length();
while(getline(i n,line))
{
cout<< line <<'\n';
cout<<len<<endl ;
}
return 0;
}
Comment