#include <stdio.h>
#include <string.h>
char string[225];
char name_file[225];
void read();void write();
main()
{
printf("\n\nNama : Timothy Kawulusan \nNIM : 1101164456\n\n");
printf("-----------------------------------------------\n");
printf("Masukkan nama file:\t");gets(name_file);
write();
system("pause");
read();
}
void write ()
{
printf("Ketik text disini:\n");
FILE *data;
strcat(name_file,".txt");
data = fopen(&name_file,"w");
gets(string);
fprintf(data, "%s\n", string);
fclose (data);
}
void read()
{
FILE *data;
data = fopen(&name_file, "r");
while (fgets(string, sizeof(string), data) != NULL)
printf("%s",string);
fclose (data);
}
Komentar
Posting Komentar
Yuk saling mengisi kekurangan setiap orang :), Kritik dan saran selalu diterima kok! :)