Delete character from a particular index from the string

C program to delete character from a particular index from the string.

Program

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 50

void main()
{
	char str[MAX];
    int i;
    int pos, len;


    printf("Enter the string\t:");
    gets(str);
    printf("Enter the position at which character is to be deleted\t:");
    scanf("%d",&pos);

    len = strlen(str);

    if(pos<=0 || pos>len)
    {
        printf("\nDeletion can not be done at this position");
        getch();
        exit(0);
    }

    for(i=pos-1;i<len;i++)
    {
        str[i] = str[i+1];
    }
    str[len-1] = '\0';

    printf("\nModified string\t:%s",str);

    getch();
}

Output

Enter the string        :welcome to coursecrux.com
Enter the position at which character is to be deleted  :12

Modified string :welcome to oursecrux.com