Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Delete in c program

huhu2323

Apprentice
Advanced Member
Messages
53
Reaction score
0
Points
26
hello po mga pro sa programming,

gumawa po ako ng codes sa c kung saan madedelete ang isang line sa .txt file ko, kaso nageeror, pacheck naman po ng error

delete()
{
struct Items item;
int del;
FILE *fp1,*fp2;
fp1 = fopen("DATA.txt","r");
fp2 = fopen("TMDATA.txt","w+");
printf("Enter Item data ID to Delete : ");
scanf("%d",&del);
clrscr();
do
{
fscanf(fp1, "%d %s %d %d %[^\n]s\n",&item.id,&item.name,&item.price,&item.qty,&item.desc);
if(feof(fp1))
{
break;
}
if((strcmp(item.id, del)) != 0)
{
fprintf(fp2,"%d %s %d %d %s\n",item.id,item.name,item.price,item.qty,item.desc);
}

}while(!(feof(fp1)));
fflush(fp2);
remove("DATA.txt");
rename("TMDATA.txt","DATA.txt");
fclose(fp1);
fclose(fp2);
printf("\nRecord Deleted.... ");
getch();
mainmenu();
}

salamat ng marami
 
Back
Top Bottom