the idea is that i type in a sentence and store it as a string... then i can choose a letter and change it to a different letter
int main(int argc, char *argv[])
{
char string[100];
char newLetter;
char oldLetter;
int i = 0;
printf("Please enter your sentence : ");
gets(string);
printf("\n\nWord is : %s" , string );
printf("\n\nTarget : ");
scanf("%s", &oldLetter);
printf("Replace with : ");
scanf("%s", &newLetter);
for ( i = 0; i < sizeof(string); i++)
{
if (string[i] == oldLetter)
{
string[i] = newLetter;
break;
}
}
printf("\n\nWord is : %s" , string );
system("PAUSE");
return 0;
}
any help in where I've gone wrong is appreciated
eg. input could be - yellow lorry red lorry
then target - r
change to - t
output - yellow lotty ted lotty