Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. void edit_member()
  2. {
  3. int ID;
  4. int slot;
  5. streampos pos;
  6. cout << "n"
  7. << "Enter member ID#: ";
  8. cin.ignore();
  9. ID = only_int();
  10. int mems = count_members();
  11. for (int a = 0; a < mems; a++)
  12. {
  13. if (ID == member[a].ID)
  14. {
  15. i_file.open("member_data.txt");
  16. for (int b = 0; b <= a; b++)
  17. {
  18. string void_data;
  19. getline(i_file, void_data, '#');
  20. pos = i_file.tellg();
  21. slot = a;
  22. }
  23. i_file.close();
  24. break;
  25. }
  26. }
  27. o_file.open("member_data.txt");
  28. cout << "nEnter new name for ID# " << ID << ": ";
  29. cin.ignore();
  30. getline(cin, member[slot].name, 'n');
  31. o_file.seekp(pos) << member[slot].name;
  32. o_file.close();
  33. load();
  34. }
  35.  
  36. member[slot].name.length()
  37.  
  38. //when you open the file in write only mode, its content deleted.
  39. //to keep the old file content, you need to open for both read and write:
  40. fstream outfile;
  41. outfile.open ("test.txt",ios::in|ios::out);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement