/*
*Copyright (c) 2014, 烟台大学计算机学院
*All rights reserved.
*文件名称:week14-1-4.cpp
*作者:高赞
*完成日期: 2015 年 6 月 6 日
*版本号:v1.0
*
*
*/
#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
int main()
{
int j=0,i=0;
string name;
cin>>name;
fstream file;
file.open(name.c_str(), ios::in);//c_str()吧string 改为 char*
if(!file)
{
cout<<name<<" can’t open."<<endl;
exit(1);
}
char ch;
while( !file.eof())
{
file.get(ch);
if(ch==32)
++j;
else ++i;
}
cout<<"非空格字符个数:"<<i<<endl
<<"空格个数:"<<j<<endl;
file.close();
return 0;
}