//Replace a character in string
#include <stdio.h>
#include<string.h>
#include<math.h>
void main(){
int a,b;
char p,q;
char str[10];
printf("ENTER THE CHARACTER =\n");
scanf("%c",& p);
printf("p= %c\n",p);
printf("ENTER YOUR STRING =\n");
scanf("%s",&str[0]);
printf("%s\n",str);
// printf("ENTER THE CHARACTER replace =\n");
scanf("%c",&q);
printf("q=%c\n",q);
for(int i=0;i<10;i++){
if(str[i]==q){
str[i]=p;
}
}
printf("THE NEW STRING=%s\n",str);
}
To embed this project on your website, copy the following code and paste it into your website's HTML: