Эта программа заменит "word"
на "****"
#include <stdio.h>
#include <string.h>
int main(void)
{
char text[] = "This a paragraph of words where a random word should be replaced with * instead of word when word is found multiple times.";
char find[] = "word ";
printf("Start: %s\n", text);
while(strstr(text, find))
{
memset(strstr(text,find), '*', strlen(find)-1);
}
printf("Result: %s\n", text);
return 0;
}
выход
Success #stdin #stdout 0s 9424KB
Start: This a paragraph of words where a random word should be replaced with * instead of word when word is found multiple times.
Result: This a paragraph of words where a random **** should be replaced with * instead of **** when **** is found multiple times.