Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void edit_member()
- {
- int ID;
- int slot;
- streampos pos;
- cout << "n"
- << "Enter member ID#: ";
- cin.ignore();
- ID = only_int();
- int mems = count_members();
- for (int a = 0; a < mems; a++)
- {
- if (ID == member[a].ID)
- {
- i_file.open("member_data.txt");
- for (int b = 0; b <= a; b++)
- {
- string void_data;
- getline(i_file, void_data, '#');
- pos = i_file.tellg();
- slot = a;
- }
- i_file.close();
- break;
- }
- }
- o_file.open("member_data.txt");
- cout << "nEnter new name for ID# " << ID << ": ";
- cin.ignore();
- getline(cin, member[slot].name, 'n');
- o_file.seekp(pos) << member[slot].name;
- o_file.close();
- load();
- }
- member[slot].name.length()
- //when you open the file in write only mode, its content deleted.
- //to keep the old file content, you need to open for both read and write:
- fstream outfile;
- outfile.open ("test.txt",ios::in|ios::out);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement