- 论坛徽章:
- 0
|
這題c++要怎樣做? 請教教小弟>﹏<
#include <iostream.h>;
#include <stdlib.h>;
#include <fstream.h>;
#include <string.h>;
int main()
{
char infile[100], buffer[100], *pch, *pch1, ch;
int total_line=0, total_word=0, total_char=0, i=0;
cout<<"Enter input file name:";
cin>;>;infile;
ifstream in(infile);
if(!in)
cout<<"Error open file...";
else
while(in.getline(infile,100, '\\n'))
{
total_line++;
if (pch = strtok (infile," ,." ){
while (pch != NULL) {
pch = strtok (NULL, " ,." ;
total_word++;
}//while (pch != NULL)
}
}//while
cout<<"It has "<<total_line<<" lines"<<endl;
cout<<"It has "<<total_word<<" words"<<endl;
cout<<"It has "<<total_char<<" characters"<<endl;
in.close();
system(" AUSE" ;
return 0;
}//main
我還欠甚麼?  |
|