#include #include #include #include int main() { FILE *infile, *outfile; int c, key, i; infile = fopen("testprog.dat", "r"); outfile = fopen("testprog.out", "w"); // Error handling routine for no input file if (!infile){ cerr << "could not open file\n"; perror(""); exit(1);} // Use this code for input from the console: // printf("Enter a char to be located: "); // key = getc(stdin); while((c = getc(infile)) != EOF ) { if ( c == '+' || c == '*' ) { fprintf(outfile," \n Found token: "); putc(c, outfile); } else ; } fprintf(outfile, "\n\n"); // close the files fclose(infile); fclose(outfile); return 0; }