//6.8
#include<iostream> #include<fstream> using namespace std; void main68() { ifstream inFile; ifstream fin; int count=0; inFile.open("2.txt"); //请将文本文件放到当前路径 if(!inFile.is_open()) { cout<<"Open Failed!"<<endl; } char ch; inFile>>ch; while(inFile.good()) { count++; inFile>>ch; } if(inFile.eof()) { cout<<"count="<<count<<endl; } system("pause"); }