1: #include <stdio.h>
2: #include <string.h>
3: void char_remove(char *str,char c)
4: {
5: char *temp = str;
6: char *cur = str;
7: int count = 0;
8: while(*temp)
9: {
10: if ( *temp == c)
11: {
12: temp++;
13: count++;
14: } else {
15: *cur++ = *temp++;
16: }
17: }
18: if ( count == 0)
19: printf("Char %c is not fount in the string\n",c);
20: }
21: main()
22: {
23: char str[100] = "aaaabbbbcccccdddddbbbbbeeeebbbbfffff";
24: char ch;
25: printf("Enter char to be string:");
26: scanf("%c",&ch);
27: char_remove(str,ch);
28: printf("Str : %s\n",str);
29: }
RTOS, Linux Kernel internal, OS-Programming C & Data Structures, Debugging, Optimizations, Makefiles and Wireless Technologies (Wi-Fi ,LTE and LTE-Advanced )
Search This Blog
Wednesday, October 28, 2015
write a program to remove particular character from a given string
Labels:
C
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment