Turn Desktop View Off
by Dinesh Thakur

In this program user ask to delete character from String using pointer concept. User declares char type array variable. User using malloc() function for the allocate the memory to the variable. Then user asks to enter the string then shifted the ptr to str variable for address reference. Then user puts the while condition to verify condition. In condition while (*ptr! =NULL) then if (*ptr!=ch) is that all the conditions got true the *ptr2 will be *ptr2++ with increment operator. And in the end the given result will be on the screen at the end.

Problem Statement:
This is C program where coder has to use pointer function for the deletion of character from string.

  1. Declare the variables.
  2. Using loop statement and control statements.
  3. Display result in the screen.

Here is C source code for Deleting the Character from the string using pointer function. The output of this program shown below. 

#include<stdio.h>

void main()
{
    char str[100],ch,*ptr,*ptr2;
    clrscr();
    ptr2=(char*)malloc(20);
    printf("Enter a String :");
    gets(str);
    printf("Enter the Character you Want to Delete :");
    scanf("%c",&ch);
    ptr = str;
    while(*ptr!=NULL)
            {
               if(*ptr!=ch)
                 {
                     *ptr2=ch;
                       ptr2++;
                 }
                     ptr++;
            }
                     printf("%s",ptr2);
                     getch();