Program to trim a given character from a string.

Answer Posted / raju kalyadapu

//Write a program to trim a Character from a Given String
#include<stdio.h>
int main()
{
int i,j;
char str[30],ch;
printf("Enter Any String: ");
gets(str);
printf("
Enter Character to Trim:");
ch=getchar();
for(i=0;i<strlen(str);i++)   
{
while(str[i]==ch)   
{
j=i;
str[i]=str[i+1];
while(j++<strlen(str))
{

str[j]=str[j+1];
}

}


}
str[i]='';
printf("
");
puts(str);
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the concatenation operator?

601


What is the difference between ā€˜gā€™ and ā€œgā€ in C?

2493


What are external variables in c?

537


Difference between pass by reference and pass by value?

648


What is echo in c programming?

548






If you know then define #pragma?

668


I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...

9649


what is bit rate & baud rate? plz give wave forms

1508


why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???

1510


What is c system32 taskhostw exe?

580


Explain continue keyword in c

576


which is an algorithm for sorting in a growing Lexicographic order

1388


Describe the order of precedence with regards to operators in C.

628


In a switch statement, what will happen if a break statement is omitted?

596


What is graph in c?

577