Hi,
I am looking for C function which takes the string and text file and searches for the string and return success or failure.
Please send me if any one has the above code
Thanks & Rgds
Chenna
Hi Chenna
Here is the code above described function ,
bool searchStringInTextFile ( char * str , char *filepath)
{
FILE *fpl;
int MAX_LEN= 4000;
char line [ MAX_LEN ] ;
memset ( line , 0 , MAX_LEN );
fpl = fopen ( filepath , "r" );
fread ( line , 2000 , 1 , fpl );
if ( ( strstr ( line , str ) != NULL))
{
cout << " String found "<< endl;
fclose(fpl);
return true;
}
else
{
cout<< "String not found " <<endl;
fclose(fpl);
return false;
}
}
This funtion taked two argument search String and filename .
It return true if string available and false if string not available
Ali Muhammad KK