Basically my code is ready, the only problem is that when I show the modified end string, it only shows me the first word (When it finds a space it ignores the rest) I know that my program stops counting when it meets "\ 0" and I also know that the space counts as "\ 0" in addition to the ENTER.
I would like to know some solution to this problem, I am new to this c ++ and I know that my mistake must be silly. This is my code:
void reemplazo(char *v, char c1, char c2)
{
int i;
for (i=0;v[i]!='void reemplazo(char *v, char c1, char c2)
{
int i;
for (i=0;v[i]!='%pre%';i++)
{
if (*(v+i)==c1)
{
*(v+i)=c2;
}
}
}
int main ()
{
char palabra[20];
char a,b;
int i;
cout << "Ingrese palabra: ";
cin >> palabra;
fflush(stdin);
cout << "Ingrese caracter a reemplazar: ";
cin >> a;
cout << "Ingrese nuevo caracter: ";
cin >> b;
reemplazo(palabra,a,b);
cout <<"resultado: ";
for (i=0;i<20;i++)
{
cout<<palabra[i];
}
return 0;
}
';i++)
{
if (*(v+i)==c1)
{
*(v+i)=c2;
}
}
}
int main ()
{
char palabra[20];
char a,b;
int i;
cout << "Ingrese palabra: ";
cin >> palabra;
fflush(stdin);
cout << "Ingrese caracter a reemplazar: ";
cin >> a;
cout << "Ingrese nuevo caracter: ";
cin >> b;
reemplazo(palabra,a,b);
cout <<"resultado: ";
for (i=0;i<20;i++)
{
cout<<palabra[i];
}
return 0;
}