问题及代码:
/*
*Copyright (c) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称:zwj.cpp
*作 者:张伟晶
*完成日期:2016年6月17日
*版 本 号:v1.0
*
*问题描述:阅读程序
*输入描述:
*程序输出:
*/
#include <iostream>
#include <cstdlib>
#include <fstream> // (1)
using namespace std;
int main()
{
fstream file;
file.open("abc.txt", ios::in); // (2)
if(!file)
{
cout<<"abc.txt can’t open."<<endl;
exit(1);
}
char ch;
int i=0;
while(file.get(ch)) // (3)
{
++i; // (4)
}
cout<<"Character: "<<i<<endl;
file.close();// (5)
return 0;
}
运行结果:
知识点总结:
文件操作
&spm=1001.2101.3001.5002&articleId=51701307&d=1&t=3&u=d8f2ecf305a14797b5f9a7d1599b23e5)
211

被折叠的 条评论
为什么被折叠?



