Raised This Month: $ Target: $400
 0% 

Check if is in file


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 12-25-2008 , 15:15   Check if is in file
Reply With Quote #1

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(iFileszBuffersizeof szBuffer 1);
      
trim(szBuffer);
 
      if(!
szBuffer[0] || szBuffer[0] == ';')
         continue;
 
      
parse(szBufferszDatasizeof szData 1);
 
      if(
equali(szDatastringstrlen(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.
__________________

anakin_cstrike is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode