#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int menu,i;
char ulang;
FILE *pf;
char karakter;
int data[5];
char nama[30],alamat[40];
char buffer[1024];
do
{
printf("Menu Utama Data Kendaraan\n");
printf("--------------------------\n");
printf("1. Show Data \n");
printf("2. Add Data \n");
printf("3. Edit Data \n");
printf("4. Remove Data \n");
printf("3. Search Data \n");
printf("--------------------------\n");
printf("Insert your selection : "); scanf("%d",&menu);
printf("\n----------------------------\n");
switch(menu)
{
case 1:
{
pf = fopen("D:/tugas/file/tugas/data.txt","r");
if (pf != NULL)
{
while ((karakter = getc(pf)) != EOF)
{
printf("%c",karakter);
}
}
else
{
printf("Fatal erorr : File coba.txt cannot be opened");
exit(EXIT_FAILURE);
}
break;
}
case 2:
{
pf = fopen("D:/tugas/file/tugas/data.txt","a+");
printf("Insert name : "); fflush(stdin); gets(nama);
printf("Insert Address : "); fflush(stdin); gets(alamat);
if (pf != NULL)
{
fprintf(pf,"Name : %s \n",nama);
fprintf(pf,"Addres : %s \n",alamat);
fprintf(pf,"---------------------------\n");
}
else
{
printf("Fatal erorr : File coba.txt cannot be opened");
exit(EXIT_FAILURE);
}
fclose(pf);
break;
}
}
printf("\nReload [y/t]: "); fflush(stdin); scanf("%c",&ulang);
system("cls");
}
while (ulang != 't') ;
//system("PAUSE");
return 0;
}
**i write a program Operating file
1.Read/show file in notepad
2. Add file in notepad
3.Delete a content in notepad
4.edit a content in notepad
5. Search a content in notepad
i have done read file and and Add a content file in the notepad
then how to delete,edit and search a content in notepad?
i'm newbie in C
this is Show and Add**
how to delete,edit and search a content in notepad?