BM Balmiki Mandal 19 Sep 2022 4 views 0 comments C Programming

Write a c program to delete some some character in given string

C Program to Delete Characters from a String

in c program to delete a specified character from a given string involves iterating through the characters in the string, copying each character to a new string unless it is the one to be deleted, and then displaying the resulting string

Write a c program to delete  some character in given string 

#include<stdio.h>
int main()
{
    char s[10],ch;
    int i,j;
    printf("Enter the string:");
    scanf("%s",s);
    printf("Enter the Charcater:");
    scanf(" %c",&ch);
    printf("Before the string:%s\n",s);
    for(i=0;s[i];i++)
    {
        if(s[i]==ch)
        {
            for(j=i;s[j];j++)
            s[j]=s[j+1];
            i--;
        }
    }
    printf("After the string:%s\n",s);
}

Output:

Enter the string: ELECTRO4U
Enter the Character: E
Before the string: ELECTRO4U
After the string: LCTRO4U

Further Reading:

Concatenating Two Strings in C: A Step-by-Step Guide

Design a function to count given character in given string

Design a function to reverse the given string

Design a function to search given character in given string in c

Design a function to reverse the word in given string

Design a function replace the words in reverse order in a given string line

Design a function to find string length in c

Design a Function to print the string character by character

Write a c program to delete some characters in given string 

Enroll Now:

[ C-Programming From Scratch to Advanced 2023-2024] "Start Supercharging Your Productivity!"

Contact Us:

  • For any inquiries, please email us at [info@electro4u.net].
  • Follow us on insta  [ electro4u_offical_ ] for updates and tips.

 

Note: If you encounter any issues or specific errors when running this program, please let me know and I'll be happy to help debug them!

0 Comments

No comments yet, Be the first to comment.

Post a Comment

Please sign in to post a comment.

Related Posts

Bit wise operators Assignment

Bitwise Operators practical assignment: Take runtime input, bit-level manipulation, and different data units r...

AG Anvesh G 27 Sep 2026
Understanding Float and Double Binary Representation in C

Understanding Float and Double Binary Representation in CIntroduction:When we store decimal numbers such as 10...

AG Anvesh G 31 May 2026
Topic-wise C Programming Interview Questions

C Programming Interview Questions – Topic Wise1. IntroductionC programming is one of the most important langu...

AG Anvesh G 30 May 2026