From d0507d4e0b5378fbbbb8667598dc558bdcb32ca6 Mon Sep 17 00:00:00 2001 From: avlindork <72280160+avlindork@users.noreply.github.com> Date: Sun, 16 Oct 2022 00:05:54 +0530 Subject: [PATCH] Create Remove character from string.c --- Remove character from string.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Remove character from string.c diff --git a/Remove character from string.c b/Remove character from string.c new file mode 100644 index 0000000..73ed703 --- /dev/null +++ b/Remove character from string.c @@ -0,0 +1,32 @@ +#include +#include + +int main() +{ + char str[100], ch; + int i, len, j; + + printf("Enter String: "); + gets(str); + + printf("\nEnter character which need to remove: "); + scanf("%c", &ch); + + len = strlen(str); + + for(i = 0; i < len; i++) + { + if(str[i] == ch) + { + for(j = i; j < len; j++) + { + str[j] = str[j + 1]; + } + len--; + i--; + } + } + printf("\nNew String: %s ",str); + + return 0; +}