#include<iostream>
#include<fstream>
using namespace std;
int main()
{
char *str=" I study C++ in ok2002.com";
int count_k=0,count_all=0;
ofstream rs;
rs.open("ok2002.txt",ios::out);
if(!rs)
cout<<"文件已打开"<<endl;
for(int i=0;str[i]!=0;i++)
{
if(str[i]=='k')
count_k++;
rs.put(str[i]);
count_all++;
}
rs.close();
cout<<"字符总数是:"<<count_all<<endl;
cout<<"其中字符k的总数是:"<<count_k<<endl;
}