I'm using binary file to update a record, the code: file.seekp(file.tellp()-sizeof(*this)); shows an error line under the minus sign. The error message is :
Error C2666 'std::fpos<_Mbstatet>::operator -': 3 overloads have similar conversions BarbershopDemo c : \users...\employeeinfo.cpp 133
void Employee::updateEmployee(char *t) {
fstream file;
file.open("file1.dat", ios::in | ios::out | ios::ate | ios::binary);
file.seekg(0);
file.read((char*)this, sizeof(*this));
while (!file.eof()) {
if (!strcmp(t, eFirstName)) {
getEmployeeData();
file.seekp(file.tellp()-sizeof(*this));
file.write((char*)this, sizeof(*this));
}
file.read((char*)this, sizeof(*this));
}
file.close();
}
void Employee::updateEmployee(char *t) {
fstream file;
file.open("file1.dat", ios::in | ios::out | ios::ate | ios::binary);
file.seekg(0);
file.read((char*)this, sizeof(*this));
while (!file.eof()) {
if (!strcmp(t, eFirstName)) {
getEmployeeData();
file.seekp(file.tellp()-sizeof(*this));
file.write((char*)this, sizeof(*this));
}
file.read((char*)this, sizeof(*this));
}
file.close();
}
I am not sure what is causing the error. Thanks for the help. what I included in my project.
#include "stdafx.h"
#include "EmployeeInfo.h"
#include<iostream>
#include <string.h>
#include <fstream>
#include<stdio.h>
#include<conio.h>
using namespace std;