[LCP]Line by line checking of file for a substring.

Steve Baker ice at mama.indstate.edu
Fri Feb 18 02:17:02 UTC 2005


"preeth k" <k_preeth at rediffmail.com> wrote:
> I have a file which consists of a no. of lines. What I want to do is line by
> line checking of the file to see if a particular substring is present in it.
> Also the contents of the file are not delimited in a regular way(ie, at some
> places it is delimited by 1 blank space whaereas at some other places it may
> be delimited by 10 or 15 blank spaces.) Please suggest a way other than awk,
> cut or strtok because I have tried all these with no effect.

  I believe the function you are looking for is:

 char *strstr(const char *haystack, const char *needle)

  Which finds the substring needle in the string haystack.  For more info,
"man strstr".

								- Steve




More information about the linuxCprogramming mailing list