POINTERS -34
Problem Description
Write a function that accepts a string using pointers. In the function ,delete all the occurrences of a given character and display the modified string on the screen (Case Insensitive)
Refer sample input and output for formatting specification.
All float values are displayed correct to 2 decimal places.
All text in bold corresponds to input and the rest corresponds to output.
CODING ARENA
#include <stdio.h>
#include <string.h>
int main()
{
char str[15],ch,cat[10];
scanf("%s%c",str,cat);
scanf("%s",&ch);
int i=0,j,len;
len=strlen(str);
for(i=0;i<len;i++)
{
if(str[i]==ch)
{
for(j=i;j<len;j++)
{
str[j]=str[j+1];
}
len--;
// i--;
}
}
printf("%s",str);
//printf("%s",cat);
return 0;
}
Test Case 1
Input (stdin)SRMUniversity
i
Expected Output
SRMUnversty
Test Case 2
Input (stdin)SRMUniversity
t
Expected Output
SRMUniversiy
Not getting the output as expected output.
ReplyDelete