#include <stdio.h>
#include <string.h>
main()
{
char str[124],str_cpy[124];
char wrd[24];
void *ret;
int i,j,cnt_str,cnt_wrd,cnt_cpy,res = 0;
printf("Enter the string: ");
ret = gets(str);
printf("Enter Word to remove: ");
ret = gets(wrd);
top:
cnt_str = strlen(str);
cnt_wrd = strlen(wrd);
ret = strstr(str,wrd);
if(ret != NULL)
{
cnt_cpy = (unsigned int)ret -(unsigned int)str;
strncpy(str_cpy,str,cnt_cpy);
str_cpy[cnt_cpy - 1] = '\0';
strncat(str_cpy, (ret + cnt_wrd),(cnt_str - cnt_wrd));
strcpy(str, str_cpy);
res++;
}
else if(res == 0) printf("Word not found\n");
else goto last;
goto top;
last:
printf("New string: %s\n",str);
}
that the answer
Copyright © 2026 eLLeNow.com All Rights Reserved.