I got a function in my class that returns a vector holding User and Pass read from an ini file.
Here's the code that reads it. I added outputs here for tests and it's reading it successfully.
vector<char*> Main::GetAccount(int i)
{
vector<char*> LoginInfo;
char szUser[13];
char szPass[13];
char szBuf[3];
_itoa_s(i, szBuf, 10);
GetPrivateProfileString(szBuf, "UserID", "User", szUser, 13, ".\\accounts.ini");
GetPrivateProfileString(szBuf, "Pass", "Pass", szPass, 13, ".\\accounts.ini");
if (strcmp(szUser, "User") == 0)
{
char szBuffer[80];
sprintf_s(szBuffer, "Cannot read account %i.", i);
Log(szBuffer);
exit(EXIT_FAILURE);
}
else
{
LoginInfo.push_back(szUser);
LoginInfo.push_back(szPass);
return LoginInfo;
}
}
And here is where I'm calling it, and where it goes wrong.
for (int i = 1; i < main->nBots + 1; i++)
{
vector<char*> LoginInfo = main->GetAccount(i);
char* szUser = LoginInfo[0];
char* szPass = LoginInfo[1];
cout << szUser << endl << szPass << endl;
}