Program in C to delete a Character from a given position in a given string
➤Program Code
#include<stdio.h> #include<string.h> int main() { char str[100]; int position,i,length=0; printf("Enter a string:-"); scanf("%s",str); printf("Enter the position from where you want to delete a character:-"); scanf("%d",&position); printf("Before deletion = %s\n",str); length=strlen(str); for(i=position-1;i<length;i++) str[i]=str[i+1]; printf("After deletion = %s\n",str); return 0; }
Output:-
Related Programs
0 Comments