I want help in my code ,, the program should search for all words in a string
For example , if the string is welcome to pointers world come and see the magic
it should print welcome come .
Any One can help me to find a way to solve it , I don't want the help in coding ..I just want an idea about how to do this :/

Edited 3 Years Ago by laila_2

Istart like this :

                #include<iostream>
                #include<cstring>
                using namespace std;
                char *all_match(char *stat,char *key);
                int main(){ 
                 char key[]="come";
                 char stat[]="welcome to pointer world come and see the magic";  //any statment
                    // cout<<strlen(stat)<<endl; the size of the statment
                 char *q=all_match(stat,key);                         
                 return 0;
                }


            char *all_match(char *stat,char *key){
                     char *pkey=key;
                     char *pstat=stat;
                     int count_word=0,i,j,k;
                         cout<<strlen(stat)<<endl;
                        for(i=0; i< strlen(stat) ;i++){
                            if(*pstat == * pkey)
                              { cout<<*pstat;
                                pstat++;
                                pkey++;
                                cou/if
                              }       
                               else
                                {

                              pstat++;
                             pkey=key;
                              } //else

                              }//for loop                  

                              }//function

and the output is come come

This article has been dead for over six months. Start a new discussion instead.