Jump to content

Redox's C++ Tutorial : Stergerea unui cuvant dat dintr-o propozitie citita.


Recommended Posts

6vc14u3.png
 
Rulat : Codeblocks.
 
#include <iostream>
#include <string.h>
 
using namespace std;
int main()
{
    char a[50],*p,cuvant[30];
    cout<<"Introduceti o propozitie: "<<endl;
    cin.get(a,50);
    cout<<"Acum introduceti un cuvant: "<<endl;
    cin>>cuvant;
    p=strstr(a,cuvant);
    while(p)
    {
        strcpy(p,p+strlen(cuvant));
        p=strstr(p,cuvant);
    }
        cout<<"Cuvantul "<<">> "<<cuvant<<" <<"<<" a fost gasit in propozitie si a fost sters."<<endl;
 cout<<a;
}
 

 

Link to post
Share on other sites
  • 7 years later...
  • 4 weeks later...
On 12/17/2021 at 3:40 PM, Blitzzzzzzzzzzzzzzz said:

ba cum functioneaza asta? de ce se schimba a cand nici nu te atingi de el?

salut. p este pointer ce pointeaza catre a, in acest fel se motifica a.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.