I am trying to create my login system but I have got a problem with reconizing the value from a file. getline(fstream) recognizes it and puts it in a char(reg_confirm), but I can't set a different function for a different value.
it should go like this:
if (value == "0") { // FUNCTION 1 }
else if (value == NULL) {// FUNCTION 2 }
else ERROR
but it always get ERROR. the value in the file is 0.
FULL CODE:
http://pastebin.com/fMvKgLa8 -- main.cpp
http://pastebin.com/Gj02beva -- defines.h
float IsRegistered()
{
char reg_confirm[256];
/* FILE * llFile;
long llSize;
size_t result;
llFile = fopen (LLOGS_FILE, "r+" );
if (llFile == NULL) { cout << "reg check error(1)." << endl; exit(1); }
fseek(llFile, 0, SEEK_END);
llSize = ftell(llFile);
rewind(llFile);
reg_confirm = (char*) malloc (sizeof(char)*llSize);
if (reg_confirm == NULL) { cout << "reg check memory error(2)." << endl; exit(2); }
result = fread(reg_confirm, 1, llSize, llFile);
if (result != llSize) { cout << "reg check reading error(3)." << endl; exit(3); } */
fstream file_op(LLOGS_FILE, ios::in);
file_op.getline(reg_confirm, 256);
file_op.close();
if (reg_confirm == "0") { RegisterScreen(); }
else if (reg_confirm == NULL) { cout << "file is null"; }
else { cout << "error"; exit(99);}
// fclose(llFile);
}