📄 lofcount.txt
字号:
#include <iostream.h>
#include <fstream.h>
int main ()
{
ifstream infile;
char x;
char filename[11];
int chartick = 0;
int rettick = 0;
cout << "Enter the filename to be examined: ";
cin >> filename;
infile.open(filename,ios::in);
infile.unsetf(ios::skipws);
if(infile)
{
while(!infile.eof())
{
infile >> x;
// cout << x; (troubleshooting purposes only)
if (x == '\n')
{
rettick++;
}
else
{
chartick++;
}
}
chartick--;
cout << "\n\nCharacter count: " << chartick;
cout << "\nEnd of line count: " << rettick;
}
else
{
cout << "\nFile failed to open";
}
infile.close();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -