What I want to do in this program is that the user enters a character that he wants to replace and the character with which he wants to replace it. I do not know if the function is right where I make the modification, but the issue is the error that marks me that I do not know how to solve it, I have already tried several things that have occurred to me but it has not happened to me!
The error is:
incompatible types in assignment of 'char' to 'char[1000]
struct modif
{ char textorig[1000];
char textmodif[1000];
int cantremp; };
char * carga (int *) ;
struct modif * modifica (char *, int, char, char);
int main()
{
char *texto,caracaremp,caracderemp;
int cantcarac,op;
struct modif *estruc;
texto= carga(&cantcarac);
printf("Ingrese una de las siguientes opciones: \n");
printf("1-Modifica \n 2-Cuenta \n 3-Busca \n 4-Salir \n");
scanf("%d",&op);
if (op==1)
{ printf("Ingrese el caracter que quiere reemplazar: \n");
scanf ("%c", &caracaremp);
printf("Ingrese el caracter de reemplazo \n");
scanf("%c", &caracderemp);
estruc= modifica(texto,cantcarac,caracaremp,caracderemp);
printf ("El texto original es: %s", estruc->textorig);
printf("El texto modificado es: %s", estruc->textmodif); }
system("PAUSE");
return 0;
}
char * carga (int *n)
{
char s[1000];
printf("Ingrese el texto presione TAB y ENTER para finalizar: \n");
scanf ("%[^\t]",&s);
*n=strlen(s);
return s; }
struct modif * modifica (char *cadena, int cc, char car, char cdr)
{
struct modif arr;
int cont=0;
arr.textorig=*cadena;
for (int i=0; i<=cc; i++)
{ if (*cadena[i]=='car')
{ *cadena[i]='cdr';
cont=cont+1;} }
arr.textmodif=*cadena;
return arr; }