/* * Project name: C4P eBook Wishlist Parser * Author: Isaac Good * Summary: TF of C4P wanted some HTML parsed with select bits stuck in a seperate text file. * This app reads a HTML file (file name given as the parameter), looks for a thread (" #include #define BUFFER_SIZE 2048 int main(int argc, char * argv[]) { FILE *inputFile, *outputFile; char inputBuffer[BUFFER_SIZE], *position; int i; // Check its c.exe FILENAME if(argc != 2) { printf("To run, type: %s FILENAME", argv[0]); return 1; } // Open input and output sources inputFile = fopen(argv[1], "r"); outputFile = fopen("out.txt", "a"); if(outputFile == NULL || inputFile == NULL) { printf("Error opening files!"); return 1; } // Write header fprintf(outputFile, "\n*-*-*-*File: %s*-*-*-*\n", argv[1]); i = 0; // Read a line while(fgets(inputBuffer, BUFFER_SIZE, inputFile) != NULL) { // See if the line got this string... position = strstr(inputBuffer, "View") != NULL) continue; i++; // Find the end of the first tag position = strstr(position, ">") + 1; // Append a null in place of the '' position[strstr(position, "") - position] = NULL; // Print to file + screen fprintf(outputFile, "#%d: %s\n", i, position); fprintf(stdout, "#%d: %s\n", i, position); } fclose(inputFile); fprintf(outputFile, "\n\n"); fclose(outputFile); return 0; }