What's new
  • Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as: All that and more! Registration is quick, simple and absolutely free. Join our community today!

c-languange pa help

genji

Addict
Joined
Feb 9, 2015
Messages
289
Reaction score
33
Age
25
Sa FILE handling pano po ba mag delete ng record /book,
may alam nako kung pano mag add, search. pero sa delete di pa
di pa kasi naturo samin,
ganito po hal. mag e-input po ang user ng book id tapos kung makita e dedelete.

ano po build-in function nagagamitin madami bang built-in func ang pweding gamitin dyan?

alam kung maliit ng bagay lang to sa inyo.
maraming salamat :D
 

Keala Yuriko Kazumori

PHC - Dyosa ®
Not sure about this but you can edit this syntax

  1. When You want to delete the record:
  2. void deleteRecord()
  3. {
  4. int enrollNo;
  5. int counter=0;
  6. FILE *ptr2 = fopen("c:\\file2.txt","a");
  7. int records = getNoOfRecords();
  8. refresh();
  9. fflush(stdin);
  10. printf("(text here)\n");
  11. scanf("%d",&enrollNo);
  12. while(counter!=records)
  13. {
  14. fread(&var,sizeof(struct student),1,ptr);
  15. if(var.enrollNo==enrollNo)
  16. {
  17. }
  18. else
  19. {
  20. fwrite(&var,sizeof(struct student),1,ptr2);
  21. }
  22. counter++;
  23. }
  24. fcloseall();
  25. remove("c:\\file.txt");
  26. rename("c:\\file2.txt","c:\\file.txt");
  27. printf("Press any key..");
  28. getch();
  29. }
 

isaac_14

Honorary Poster
Not sure about this but you can edit this syntax

  1. When You want to delete the record:
  2. void deleteRecord()
  3. {
  4. int enrollNo;
  5. int counter=0;
  6. FILE *ptr2 = fopen("c:\\file2.txt","a");
  7. int records = getNoOfRecords();
  8. refresh();
  9. fflush(stdin);
  10. printf("(text here)\n");
  11. scanf("%d",&enrollNo);
  12. while(counter!=records)
  13. {
  14. fread(&var,sizeof(struct student),1,ptr);
  15. if(var.enrollNo==enrollNo)
  16. {
  17. }
  18. else
  19. {
  20. fwrite(&var,sizeof(struct student),1,ptr2);
  21. }
  22. counter++;
  23. }
  24. fcloseall();
  25. remove("c:\\file.txt");
  26. rename("c:\\file2.txt","c:\\file.txt");
  27. printf("Press any key..");
  28. getch();
  29. }
wow 1st step pa lang hindi ko masundan
 

genji

Addict
oo c palang languange tinuturo samin hehe
ahm ito ba yung pa-isa isang delete ng record lang o lahat ng record delete ?
halimbawa sa student.txt may record ng mga student dun
I.D NAME LASTNAME
1234 john doe
1235 kaela yuriko
1515 isaac ewan
ngayon gusto ko e delete si isaac pano?
anong built-in function gagamitin?
sa pagkakaintindi ko sa itaas na tinuro mam kaela
parang lahat ng student.txt ma re remove? tama ba?
 

Unanswered Topics

Online statistics

Members online
590
Guests online
695
Total visitors
1,285

Forum statistics

Threads
833,109
Messages
14,729,368
Members
1,351,915
Top