What I do here is convert my input name to char then check from the text file if char a which is the input name exists or equal to existing nameData. nameData is the variable stored in the text file. But my program crashed once it detects that the input is new. What may seemed the problem in this problem? I'm getting the crash from else condition part.
char *nameData;
char *passData;
QByteArray nameBa;
nameBa = name.toLatin1();
nameData = nameBa.data();
passData = pass.data();
char *a;
QByteArray aBa;
aBa = name.toLatin1();
a = aBa.data();
std::fstream dataProfile;
dataProfile.open("D:/Data.txt", std::ios::in);
while(!dataProfile.eof())
{
dataProfile.getline(nameData, 90, ' ');
dataProfile.getline(passData, 90);
if(std::strcmp(nameData, a)==0)
{
std::cout << "Profile Already exists\n";
//if break here, still crash to else condition
}
else
{
std::cout << "Not Exists\n";
}
break;
}