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