I tried with this method but the output remains the same as the input. The user enters the character he wants to replace and with which letter he wants to replace with. I don't understand where did I go wrong.
#include<stdio.h>
char* replaceChar(char *s, char x,char y)
{
int i=0;
while(s[i])
{
if(s[i]==x)
{
s[i]==y;
}
i++;
}
return s;
}
int main()
{
char string[30];
printf("Enter the string:\n");
gets(string);
fflush(stdin);
char x;
char y;
printf("Enter the character you want to replace:\n");
scanf("%c",&x);
printf("Enter the character you want to replace with:\n");
scanf(" ");
scanf("%c",&y);
printf("After replacing the string :\n");
printf("%s",replaceChar(&string[0],x,y));
return 0;
}