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 :/

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.