The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 04-16-2009
Zykl0n-B Zykl0n-B is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 25
Thank You!!!, Thanks man,... Thank you...

I corrected 'fgets' and 'if' functions...

Code:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
        FILE *fp=fopen(argv[1],"r");
        char  tmp[256]={0x0};
        while(fp!=NULL && fgets(tmp, sizeof(tmp),fp)!=NULL)
        {
        if (strstr(tmp, argv[2]))
        printf("%s", tmp);
        }
        if(fp!=NULL) fclose(fp);
        return 0;
}