#include int getlinks(char *sourcefile, char *targetfile) { FILE *in_file, *out_file; char c, url[512]; int i = 0; if((in_file = fopen(sourcefile, "r")) == NULL) return -1; if((out_file = fopen(targetfile, "w")) == NULL) return -1; while((c = fgetc(in_file)) != EOF){ if(c == '<'){ if(((c = fgetc(in_file)) == 'a') || c == 'A'){ if((c = fgetc(in_file)) == ' '){ while(((c = fgetc(in_file)) != '\'') && (c != '\"')); while(((c = fgetc(in_file)) != '\'') && (c != '\"')){ url[i] = c; i++; } url[i] = '\0'; i = 0; fprintf(out_file, "%s\n", url); } } } } fclose(in_file); fclose(out_file); return 0; }