answersLogoWhite

0


Best Answer

#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

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C program to delete a word from a sentence?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Crossfire game not working?

to fix this, simply delete the Crossfire program files, then reinstall. (go to c: then open 'program files', now look for "z8" and delete it.)


C program to accept a sentence using scanf?

scanf ("%[^\n]s", sentence);


How do you write c program to delete source code after execution?

Use function unlink to erase files.


After you install a new software your PC is stuck to boot what should you do?

Uninstall the software, delete the program's folder from Program Files in C:\ and then virus scan.


Write a C program to extract a given word from a file?

program to extract a given word from a file


Which one of the following items is an example of software A Word-processing program B Keyboard C Printer D Mouse?

Word-processing program


What is the unstressed vowel in the word sentence?

The unstressed vowel in the word &quot;sentence&quot; is the second &quot;e&quot; sound.


My computer doesn't have a delete option for a certain program How do i delete it?

If you can't find the uninstall button, then go Start-&gt;Accessories-&gt;Command Prompt and then type RMDIR pathofprogram. An example might be like this: RMDIR C:\Program Files\Cant Uninstall Me


How to remove the antivirus program?

don't bother. it does not infect your computer as whole only the user a/c. create a new user a/c re-install all your info in new a/c then delete infected a/c.


How do you deleate a profile on cod2?

Delete your folder from the players folder c:/program files (86x)/activision/call of duty 2


C program to find the largest and smallest character in a word?

helicopter


How do you write a c program to find a word in a string?

what is if(!(str[i]==32))