#include <stdio.h>
#include <string.h>
int main()
{
char a[250];
char c1[1],c2[1];
int n,i;
printf("Give text: ");
gets(a);
printf("Give c1: ");
gets(c1);
printf("Give c2: ");
gets(c2);
n=strlen(a);
for(i=0;i<n;i++)
{
if(a[i]==c1)
{
a[i]=c2;
}
if(a[i]==c2)
{
a[i]=c1;
}
}
printf("%s",a);
return 0;
}
In a text I need to switch c1
with c2
and reverse,
but when I start the program after I give a, c1
, c2
nothing happened.
Where am I wrong?