la luna
This commit is contained in:
parent
ad3ca97c44
commit
c7132e6b75
55
main.c
55
main.c
|
|
@ -6,47 +6,58 @@ FILE *fptr;
|
||||||
|
|
||||||
void sf() {
|
void sf() {
|
||||||
fptr = fopen("data.txt", "rb+");
|
fptr = fopen("data.txt", "rb+");
|
||||||
if ( fptr == NULL ) {
|
if (fptr == NULL) {
|
||||||
printf("OK! data.txt\n");
|
printf("Sukses buat data.txt\n");
|
||||||
fptr = fopen("data.txt", "wb");
|
fptr = fopen("data.txt", "wb");
|
||||||
|
if (fptr == NULL) {
|
||||||
|
perror("Galat buat data.txt");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int main(int argc, char *argv[]) {
|
||||||
void parser(char * s) {
|
if (argc < 2) {
|
||||||
int n = strlen(s);
|
printf("Penggunaan: %s <berkas_input>\n", argv[0]);
|
||||||
int start = 0, end = 0;
|
return 1;
|
||||||
int i, j;
|
}
|
||||||
|
|
||||||
for(i = 0; i < n; i++) {
|
|
||||||
if(s[i] == '_') {
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
int main(int argc, char * argv[]) {
|
|
||||||
sf();
|
sf();
|
||||||
|
|
||||||
if(argc == 1) {
|
for (int i = 1; i < argc; i++) {
|
||||||
printf("not enough parameter\n");
|
if (strcmp("-v", argv[i]) == 0) {
|
||||||
return -1;
|
printf("ini -v\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *txt = malloc(1024);
|
char *txt = malloc(1024);
|
||||||
|
if (txt == NULL) {
|
||||||
|
perror("Galat alokasi memori");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
fptr = fopen(argv[1], "rt");
|
fptr = fopen(argv[1], "rt");
|
||||||
|
if (fptr == NULL) {
|
||||||
|
perror("Galat membuka masukan berkas");
|
||||||
|
free(txt);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
FILE *fpto = fopen("data.html", "wb");
|
FILE *fpto = fopen("data.html", "wb");
|
||||||
|
if (fpto == NULL) {
|
||||||
|
perror("Galat membuat keluaran berkas");
|
||||||
|
fclose(fptr);
|
||||||
|
free(txt);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
while(fgets(txt, 1024, fptr ) != NULL) {
|
while (fgets(txt, 1024, fptr) != NULL) {
|
||||||
for(int i = 0; i < strlen(txt); i++) {
|
|
||||||
if(txt[i] == '_') {
|
|
||||||
}
|
|
||||||
fprintf(fpto, "<p>%s</p>\n", txt);
|
fprintf(fpto, "<p>%s</p>\n", txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fptr);
|
fclose(fptr);
|
||||||
fclose(fpto);
|
fclose(fpto);
|
||||||
free(txt);
|
free(txt);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user