Return to Snippet

Revision: 61948
at January 25, 2013 07:35 by bcnjr5


Initial Code
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

char srch(char *string_to_find, char *filename)
{
FILE *fp=fopen("M", "r");
char  tmp[256]={0x0};
while(fp!=NULL && fgets(tmp, sizeof(tmp),fp)!=NULL)
{
if (strstr(tmp, string_to_find))
printf("%s", tmp);
}
if(fp!=NULL) fclose(fp);
return tmp;
}

Initial URL

                                

Initial Description
usage:
srch(foo, bar.txt)

Initial Title
Search file for string

Initial Tags

                                

Initial Language
C