-->

Sunday, 9 April 2017

searching a string in file -c program




#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char yourtext[20]="europe";
char file[20]="filename";
char buf[100];
FILE *fp=fopen("file.txt","a+");
char *p;
//fgets is a function which takes a //line input from a file till a new line //character fgets(char[ ],int,FILE *)
while(fgets(buf,100,fp))
{
      p=strstr( buf , yourtext);
      if(p!=NULL)
      {
              printf("%s",p);
              exit(0);
       }
}
printf("Not found\n ");
return 0;
}

keep calm and say bujuku bujuku.

0 comments:

Post a Comment

Start Work With Me

Contact Us
KUTTY SELVA
+91 7708139984
Madurai,Tamilnadu