+ 1

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; } }

5th Aug 2021, 3:57 AM
Atul Chourasiya
Atul Chourasiya - avatar
1 Resposta
+ 1
It's not C nor Java nor php nor html, why did you use all those tags? The code is too dense (it's unreadable), no one will spend time trying to read it, so just put it in codeplayground (with proper indentation and spacing) and link it here Good luck!
26th Aug 2021, 1:47 AM
Angelo
Angelo - avatar