- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrep_.cpp
More file actions
Latest commit
24 lines (22 loc) · 449 Bytes
/
Copy pathgrep_.cpp
File metadata and controls
24 lines (22 loc) · 449 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
usingnamespacestd;
intmain()
{
char fn[10] , pat[10] , temp[1000];
FILE *fp;
cout<<"\nenter file name:";
cin>>fn;
cout<<"\nEnter pattern to be searched:";
cin>>pat;
fp = fopen(fn,"r");
while(!feof(fp)){
fgets(temp,1000,fp);
if(strstr(temp,pat))
cout<<temp;
}
fclose(fp);
return0;
}