#include
#include
using namespace std;
int main()
{
int lines = 0 , words = 0 , letters = 0;
ifstream ifile;
ifile.open("1.txt",ios::in);
char ch;
int iret = -1;//-1 未知 0 非字母 1 字母
while(!ifile.eof())
{
//ifile>>ch;//该方法不能读取空格回车
ifile.get(ch);
cout< letters++;
if (ch!=' '&&ch!='\n'&&ch!=','&&ch!='.')//字母
{
iret = 1;
}
//字母后第一出现逗号、句号、回车或空格 单词数+1
if ((ch==' '||ch == ','||ch=='.'||ch=='\n')&&iret==1)
{
words++;
iret = 0;
}
if (ch=='\n')
{
lines++;
iret = 0;
}
}
lines++;//最后一行无回车补上
cout<
return 0;
}
//空格 逗号 句号 回车 我都算成字符了