C Program to Delete Words from Sentence

Problem:- C Program to Delete Words from Sentence or C Program to Remove given Word from a String or C program to remove all occurrences of a word in string or C Program to Delete the Word in String or C program to remove the occurrence of the word from entered string or Write a C program to remove a specified word from a sentence or C program to Delete all occurrences of Character from the String or Delete a word from a string or C program to delete vowels from a string or C Program to Remove all Characters in a String Except Alphabet or C program to remove consecutive repeated characters from String or Delete particular word from string or c program to delete a substring from a string.

Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

Explanation:- Just like a searching an element in a sentence or in the string we have to perform the same operation for delete the particular word in a string or sentence. for that we have to first find the word is present in the string on sentence after that remove the word from the string or sentence. So first run a loop for main string and compare the string to substring, for each iteration increase the value of index if the substring is matched with the main string. then remove or if you want to print only the output so you can skip the character from main strings.

Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page.



void main()
/*Visit - www.programmingwithbasics.com*/
    printf("\nVisit - www.programmingwithbasics.com");
    int i, j = 0, k = 0,n = 0;
    int flag = 0;
    char str[100], new[100], word[100];

    printf("\n\nEnter Any String: ");

    printf("\n\nEnter Any Word You Want to be Removed: ");

    for(i = 0 ; str[i] != '\0' ; i++)
        k = i;
        while(str[i] == word[j])
            if(j == strlen(word))
                flag = 1;
    j = 0;

    if(flag == 0)
        i = k;      
        flag = 0;

    new[n++] = str[i];

    new[n] = '\0';
    printf("\n\nAfter Removing Word From String: %s\n",new);


C Program to Delete Words from Sentence

You May Also See

1. C Program For Checking You Are Eligible For Voting Or Not

2. C Program For Finding Greater Between Two Number

3. C Program For Checking Number Is Even Or Odd

4. C Program For Check Leap Year Or Not Using If /Else Statement

5. C Program For Check Character Is Vowel Or Not Using If Else Statement

6. C++ Program To Find Quotient And Reminder Of Two Numbers Using If/Else Statements

7. C++ Program To Convert A Lowercase Alphabet To Uppercase Alphabet Or Vice-Versa Using If/Else Statements

8. C++ Program To Find Max Number Among Given Three Number Using If/Else Statements

9. C++ Program To Check Year Is Leap Year Or Not Using If/Else Statements

10. C++ Program To Find The HCF Or LCM Of Two Number Using If/Else Statements

Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me