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 [[email protected]].
- 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!