#include #include #include #include #define MAX_LINE_LEN 512 int main (int argc, char **argv) { FILE *fp; // file pointer char fm[] = "r"; //open file mode - read only char text_line[MAX_LINE_LEN]; char java[32]; char readfile[64]; char hyperlink[512]; char new_line[512]; if ((fp = fopen(argv[1], fm)) == NULL) { printf ("Opening file %s FAILED.\n", argv[1]); exit(0); } fgets(text_line, MAX_LINE_LEN, fp); sscanf (text_line, "%s %s %s", java, readfile, hyperlink); fclose (fp); sprintf (new_line, "java netarchiver %s", hyperlink); char cmd[256]; if ((fp = fopen("tmp.txt", "wa")) == NULL) { printf("Opening tmp.txt FAILED.\n"); exit (0); } fputs (new_line, fp); fclose (fp); sprintf (cmd, "mv tmp.txt %s", argv[1]); system (cmd); return 1; }