Code:
int main(array<System::String ^> ^args)
{
char sentence[100];
char toReplace[20];
char replacement[20];
printf("Enter a sentence: ");
fgets(sentence, 100, stdin);
char *pos = strstr(sentence, toReplace);
while (pos == NULL){
printf("Enter the word you want to replace: ");
scanf("%s",&toReplace);
pos = strstr(sentence, toReplace);
if(pos != NULL)
break;
printf("! Error: %s does not exist.\n", toReplace);
}
// if found
if (pos != NULL) {
printf("Enter the new word: ");
scanf("%s",&replacement);
Okay, I solved 90% of this problem. Here is the first half of my main, see if you can complete the rest. I will try to finish it as well (just to see how do to it myself, since I am also (re)learning c).