1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
fstream bucky;
char c[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
int f[26] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
string file_input = argv[1];
bucky.open( file_input );
if( !bucky.is_open() )
{
cout << "Cannot open " << file_input << " for input" << endl;
exit( EXIT_FAILURE );
}
cout << "debug1" << endl;
char ch;
string cur;
while( bucky.good() ){
bucky >> cur;
for(int i=0; i<cur.length(); i++){
ch = cur[i];
f[ ch - 97] = f[ ch - 97] + 1;
}
}
|