#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
Chat with our AI personalities
You don't write an algorithm for a C++ program, unless you are documenting the C++ program after-the-fact. The normal procedure is to write the algorithm first, in a language independent fashion, and then translate that stated algorithm into C++ code, or into whatever language you wish.
(A + B) + C = A + (B + C) = A + B + C
Cardiac arrest
Assuming this is C, DWORD is of type unsigned long. Its max value can vary depending on the word length of the system the program is run on. To be safe, include limits.h, and use ULONG_MAX for the maximum value.
mano ni anda yarrr