allo darlin'
This commit is contained in:
parent
c65dbcfb4a
commit
8500194b07
26
main.c
26
main.c
|
|
@ -30,42 +30,32 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *txt = malloc(1024);
|
char txt[50], of[50];
|
||||||
if (txt == NULL) {
|
|
||||||
perror("Galat alokasi memori");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *of = malloc(strlen(argv[1])+6);
|
|
||||||
if (of == NULL) {
|
|
||||||
perror("Galat alokasi memori of");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
strcpy(of, argv[1]);
|
strcpy(of, argv[1]);
|
||||||
strcat(of, ".html");
|
strcat(of, ".html");
|
||||||
|
|
||||||
fptr = fopen(argv[1], "rt");
|
fptr = fopen(argv[1], "rt");
|
||||||
if (fptr == NULL) {
|
if (fptr == NULL) {
|
||||||
perror("Galat membuka masukan berkas");
|
perror("Galat membuka masukan berkas fptr\n");
|
||||||
free(txt);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *fpto = fopen(of, "wb");
|
FILE *fpto = fopen(of, "wb");
|
||||||
if (fpto == NULL) {
|
if (fpto == NULL) {
|
||||||
perror("Galat membuat keluaran berkas");
|
perror("Galat membuat keluaran berkas fpto\n");
|
||||||
fclose(fptr);
|
fclose(fptr);
|
||||||
free(txt);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fgets(txt, 1024, fptr) != NULL) {
|
fprintf(fpto, "<html>\n");
|
||||||
|
while (fgets(txt, 50, fptr) != NULL) {
|
||||||
fprintf(fpto, "<p>%s</p>\n", txt);
|
fprintf(fpto, "<p>%s</p>\n", txt);
|
||||||
}
|
}
|
||||||
|
fprintf(fpto, "</html>");
|
||||||
|
|
||||||
fclose(fptr);
|
fclose(fptr);
|
||||||
fclose(fpto);
|
fclose(fpto);
|
||||||
free(txt);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user