Originally Posted by
iMalc
Is there an entry called "(null)" on the last line of the text file, or are there over 500 lines?
You can't do this in C++, so what is your real code?:
My mistake, was kind of doing that from memory. And I was trying to put it in format of a console. Oh and I was just trying to fix it when I did, I thought it might be doing some huge loop and freezing. I noticed when it reads an empty line it equates to (null), so I thought I'd just stop reading at that point.
Code:
char *mysprintf(CHAR* szFormat, ...)
{
CHAR *szString = new CHAR[8192];
::memset(szString, 0, 8192);
va_list vaArgs;
va_start(vaArgs, szFormat);
vsprintf(szString, szFormat, vaArgs);
va_end(vaArgs);
return szString;
delete[] szString;
}
BOOL File2Array(LPSTR pArray[], char *szFile)
{
int i = 0;
std::ifstream file(szFile);
if (file.is_open()) {
std::string line;
while(std::getline(file, line))
{
pArray[i] = mysprintf("%s", line.c_str());
i++;
if(i > 500)
return TRUE;
}
}
else {
Print("Unable to open file.");
return FALSE;
}
return TRUE;
}
BOOL IsFriendlisted(char *szPlayer)
{
for(int i = 0; _strcmpi(FriendList[i], "(null)") != 0 && i < 500; i++)
if(!_strcmpi(FriendList[i], szPlayer))
return TRUE;
return FALSE;
}
#define DEFINEVAR(type, name) extern type name;
DEFINEVAR(LPSTR, FriendList[512])
if(!_strcmpi(Msg[0],"test"))
{
char *Word;
Word = "apple";
Print("%d", IsSquelchListed(mysprintf("%s", Word), false));
return true;
}
Thanks for reply,
Vivec45