#include<iostream>
#include<fstream>
using namespace std;
int main() {
char finname[80];
char ch;
int b2=0, b1=0, space=0;
cout << "\nEnter input file name: ";
cin >> finname;
ifstream fin(finname);
while(fin.get(ch)) {
cout<<ch;
if(ch&128) {
b2+=1;
fin.get(ch);
cout<<ch;
} else {
if(ch==' ') {
space+=1;
} else {
b1+=1;
}
}
}
fin.close();
cout<<endl;
cout<<"2byte 글자수 : "<<b2<<endl;
cout<<"1byte 글자수 : "<<b1<<endl;
cout<<"공백수 : "<<space<<endl;
cout<<"전체 바이트 수 : "<<2*b2+b1+space<<endl;
return 0;
}
'c·c++ > c++ 프로그래밍' 카테고리의 다른 글
bool 형에 대해서 (0) | 2014.04.02 |
---|---|
longest common substring (0) | 2014.03.31 |
zigzag (0) | 2013.10.22 |
최대공약수 구하기 (0) | 2013.10.05 |
2진수를 10진수로 바꾸기 (0) | 2013.10.05 |