Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include<iostream.h>
- #include<process.h>
- #include<conio.h>
- void search(int n);
- void print(char temp[50],int i,int n);
- char str[50][50];
- int main()
- {
- int n;
- cout<<"\nEnter the no of words ";
- cin>>n;
- for(int i=0;i<n;i++)
- {
- cout<<"\nEnter word no "<<(i+1)<<" ";
- gets(str[i]);
- }
- search(n);
- return 0;
- }
- void search(int n)
- {
- char temp[50],ch;
- int i=0;
- clrscr();
- cout<<"\nEnter string to search ";
- while(1)
- {
- ch=getch();
- clrscr();
- if(ch!='~')
- {
- if((int)ch==8)
- {
- i=i-1;
- if(i<0)
- i=0;
- temp[i]='\0';
- cout<<"\nEnter string to search ";
- puts(temp);
- print(temp,i-1,n);
- }
- else
- {
- temp[i]=ch;
- temp[i+1]='\0';
- cout<<"\nEnter string to search ";
- puts(temp);
- print(temp,i,n);
- i++;
- }
- }
- else
- exit(0);
- }
- }
- void print(char temp[50],int i,int n)
- {
- int f=1;
- for(int a=0;a<n;a++)
- {
- f=1;
- for(int b=0;b<=i;b++)
- {
- if(str[a][b]!=temp[b])
- {
- f=0;
- break;
- }
- }
- if(f == 1)
- {
- puts(str[a]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment