Hallo, ich bins mal wieder...
Ich habe folgendes Problem:
Die "auth.ini" hat folgenden Inhalt:
Dies ist mein Programcode:
Und hier gibt es das Problem:
gcc meldet:
(Zwei mal: für "authuser" und "authpass")
Und nun meine Frage:
Wie kann ich die Syntax so "umstellen", dass wenn "authuser" und "authpass" richgtig sind, das Program weiter geht und wenn "authuser" oder "authpass" falsch sind, das Program eine MessageBox ausgibt, und sich dann beendet?
Ich freue mich über eure Hilfe
Gruß Hallasas
Ich habe folgendes Problem:
Die "auth.ini" hat folgenden Inhalt:
Code:
[Authentication]
user=username
pass=password
Code:
#include <fstream.h>
#include <windows.h>
#define DEFAULTVALUE_MATCHES (4711)
using namespace std;
int main()
{
ifstream authfile("auth.ini");
if(authfile)
{
return 0;
}
else
{
MessageBox(NULL, "Authentication failed!", "Fatal Error",
MB_OK | MB_DEFBUTTON1);
return -1;
}
char authuser = GetPrivateProfileInt("Authentication","user",
DEFAULTVALUE_MATCHES, "./auth.ini");
char authpass = GetPrivateProfileInt("Authentication","pass",
DEFAULTVALUE_MATCHES, "./auth.ini");
if(authuser == "username" && authpass == "password")
{
return 0;
}
else
{
MessageBox(NULL, "Wrong username and/or password", "Fatal Error",
MB_OK | MB_DEFBUTTON1);
return -1;
}
return 0;
}
Code:
...
if(authuser == "username" && authpass == "password")
...
Code:
error: ISO C++ forbids comparison between pointer and integer
error: ISO C++ forbids comparison between pointer and integer
Und nun meine Frage:
Wie kann ich die Syntax so "umstellen", dass wenn "authuser" und "authpass" richgtig sind, das Program weiter geht und wenn "authuser" oder "authpass" falsch sind, das Program eine MessageBox ausgibt, und sich dann beendet?
Ich freue mich über eure Hilfe
Gruß Hallasas