Delete first occurrence of character from the string

C program to delete first occurrence of character from the string.

Program

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

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

    printf("Enter the string\t:");
    gets(str);
    printf("Enter the character that is to be deleted\t:");
    scanf("%c",&ch);

    len = strlen(str);

    for(i=0;i<len;i++)
    {
        if(ch == str[i])
        {
            pos = i+1;
            break;
        }
    }

    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 character that is to be deleted       :c

Modified string :welome to coursecrux.com