Here is the code :
这里是代码:
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iterator>
using namespace std;
int main(int argc, char** argv)
{
ifstream myfile (argv[1]);
char ch;
char operator_symbols[]={'+','-','*','<','>','&','.',
'@','/',':','=','~','|','$',
'!','#','%','^','_','[',']',
'{','}','\"','`','?'
};
while(!myfile.eof())
{
myfile.get(ch);
if(isalpha(ch))
{
cout << "isalpha " << ch << endl;
}
else if(isdigit(ch))
{
cout << "is num " << ch << endl;
}
else if(find(begin(operator_symbols), end(operator_symbols), ch) != end(operator_symbols))
{
cout << "is operator sym" << ch << endl;
}
else if(ch == '(' || ch == ')' || ch == ';' || ch == ',')
{
cout << "is punctuation " << ch << endl;
}
else if (isspace(ch))
{
cout << "is space " << ch << endl;
}
}
}
#include <iostrea