C++ primer plus第六版课后编程题答案6.8


//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");





}

 

 


发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注