问题 填空题

有以下程序:
#include <iostream>
#include <fstream>
using namespace std;
int main()

fstream file;
file.open("abc.txt", ios_base::in);
if (! file )

cout<<"Can not open abc.txt"<<end1;
abort();

char ch;
int i = 0;
while ( ! file.eof() )

file.get(ch);
i++;

cout<<"Characters : "<<i<<end1;
file.close();
return 0;

程序实现的功能是 【15】

答案

参考答案:统计文件abc.txt中的字符个数

解析: 程序中通过while循环,逐个读取当前输入位置的字符,直到文件结尾,同时用变量i记录读取的次数,即文件中字符的个数。

选择题
单项选择题