#include <stdio.h>
#include <string.h>
void delchar(char *x,int a, int b);
int main()
{
char string[10];
int n,pos,p;
//clrscr();
puts("Enter a string :");
fgets(string,10,stdin);
printf("Enter the position from where you want to delete:");
scanf("%d",&pos);
printf("Enter the number of characters to be deleted :");
scanf("%d",&n);
delchar(string, n,pos);
}
// Function to delete n characters
void delchar(char *string,int n, int pos)
{
if ((n+pos-1) <= strlen(string))
{
strcpy(&string[pos-1],&string[n+pos-1]);
puts(string);
}
}
To embed this program on your website, copy the following code and paste it into your website's HTML: