Is tellp() functions imp to write on file c++
Hello coders ...i dont understand why but my code work well with fptr.tellp(); but when i comment it pin value doesn't update in file ... Can anyone tell me what wrong with this :- My code Int Bank::Resetpin() { string name_1; int pin_1; cout << space << "\t Enter UserID : "; cin >> name_1; Cin.ignore(); fstream fptr; fptr.open("Accountdetail.txt", ios::in | ios::ate | ios::out | ios::binary); if (!fptr) {cout << "\n Error404::file not found" << endl; getch(); _Exit(0); } fptr.seekg(0); while (!fptr.eof()) { fptr.read((char *)this, sizeof(*this)); if (name_1.compare(name) == 0) {cout << space << "\t Enter New Pin: "; cin >> pin_1; cin.ignore(); pin = pin_1; fptr.seekp(-(sizeof(*this)), ios::cur); fptr.write((char *)this, sizeof(*this)); cout<<fptr.tellp();. /*Here whenever i write tellp();function pin change update in file otherwise it doesn't show any update ...why?*/ cout << space << "\n\t Pin Changed Successfully " << endl; getch(); fptr.close(); return 0; } }