Hi, can anyone help me with this program.
the program inputs a string and replace the first char with the second
one.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX 200
int main(void)
{
char myString[MAX];
char getCh;
char setCh;
int i = 0;
printf("Please enter the string: ");
gets(myString);
printf("Input first char: ");
scanf("%c", &getCh);
printf("input second char: ");
scanf("%c", &setCh);
for(i=0; i<strlen(myString); i++)
if(myString[i] == getCh)
myString[i] = setCh;
printf("Final result: %s\n", myString);
return 0;
}