c++ - linked list and file Handling -
i have tried write , read linked list in file couldn't succeed. file written program cannot read linked list file.
this code:
case 2: temp = first; while (temp != null) { temp->output(temp); temp = temp->next; } break; case 3: // write in file fstream file; file.open("group.dat", ios::app | ios::out | ios::in | ios::binary); { temp = first; while (temp != null) { file.write(reinterpret_cast<char*>(&temp), sizeof(user)); temp = temp->next; } } exit(-1); case 4: // read file fstream file; file.open("group.dat", ios::app | ios::out | ios::in | ios::binary); file.seekg(0); while (!file.eof()) { file.read(reinterpret_cast<char*>(&temp), sizeof(user)); }
Comments
Post a Comment