Hi!
I want to check if a string is in a file.
For example: in the file i have:
Code:
BAILOPAN
Freecode Alka
Exolent
And i want to check if 'Alka' is in that file (space between strings, or new lines)
I tried using this, wich i found is no mine
PHP Code:
stock bool:is_string_in_file(file[], const string[])
{
new iFile = fopen(file, "rt");
if(!iFile)
return false;
new szBuffer[64], szData[32];
while(!feof(iFile))
{
fgets(iFile, szBuffer, sizeof szBuffer - 1);
trim(szBuffer);
if(!szBuffer[0] || szBuffer[0] == ';')
continue;
parse(szBuffer, szData, sizeof szData - 1);
if(equali(szData, string, strlen(string)))
{
fclose(iFile);
return true;
}
}
fclose(iFile);
return false;
}
but is not working, or using 'str_piece' from Alka's Extra precacher...ofcourse, i the file i've put instead of spaces a token.
Anyway, help would be apreciated.
__________________