answersLogoWhite

0

#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);

}

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

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

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


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

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


Write a PHP program to check whether the string is palindrome or not?

You can do this: &lt;?php if ( $word === strrev( $word ) ) { echo "The word is a palindrome"; } else { echo "The word is not a palindrome"; }


Write a Java Program to find occurences of given word in a text?

Check the documentation of the String class, for a method that searches for a substring.


Write a c program to count the number of word in a string?

#include&lt;stdio.h&gt; void main() { int cnt=0,i; char str[100]; printf("Enter the string "); scanf("%s",str); for(i=0;i&lt;strlen(str)-1;i++) { if(str[i]==' ') cnt++; } printf("\nTotal no. of word in string = %d",cnt); }


Write a C program to convert an upper case word to lower case and vice-versa.?

You would use the ToUpper and ToLower functions. string name = "XVengeance"; string upperName = name.ToUpper(); string lowerName = name.ToLower(); Console.WriteLine(upperName); Console.WriteLine(lowerName); Console.ReadLine(); I don't think I'm supposed to do your homework for you, but this code should get you started on making a more dynamic program.


use the word program as a direct object?

Write a program for this process.


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

program to extract a given word from a file


How do you write a program in C to check whether a word is a palindrome or not?

It is a simple program. i think u may understand it :#include#include#includevoid main(){char s[10]=answers.com;char x[10];int a;clrscr();strcpy(x,s);strrev(s);a=strcmp(s,x);if(a==0){printf("the entered string is palindrome");}else{printf("the entered string is not palindrome");}output:given string is not palindrome


How to write Java program for find longest word in a string?

class LongestWord{String str = "Ram is intelligent boy";String stringArray[] = str.split("\\s");public String compare(String st1, String st2){if(st1.length()>st2.length()){return st1;}else{return st2;}}LongestWord(){String word = "";for(int i=0;i


How you say grandma in java?

In Java, if you want to represent the word &quot;grandma,&quot; you can simply use a string variable. For example: String grandma = &quot;grandma&quot;; This will store the word &quot;grandma&quot; in the variable named grandma. You can then use this variable in your program as needed.


The delete and keys on the keyboard will delete a word from PowerPoint?

Yes, the delete key can delete a word from powerpoint if the word you want deleted goes after the cursor or if you highlight the word, you can press the delete key instead of the backspace.