int main()
{
char arr[20], charo, cha;
int len, score=0;
printf("Enter the line: ");
scanf("%[^\n]%*c", arr);
printf("Enter the letter you want to search for: ");
scanf("%c", &charo);
printf("Enter the letter you want to exchange: ");
scanf("%c", &cha);
len = strlen(arr);
for(int i=0; i<len; i++)
if(arr[i] == charo)
{
arr[i] = cha;
}
for(int i=0; i<len; i++)
{
printf("%s", arr);
}
}
I wanted to take a string as an input and then select a letter and replace that letter with another letter taken as an input from the user. But the third scanf doesn't work.