C program to read a string and remove anything written inside closed brackets '(' ,')':
#include<stdio.h>
int main()
{
char s[200],temp;
int
l,i=0,flag=1,j;
printf("\n
Enter the string:");
do
{
s[i]=getchar();
}
while(s[i++]!='\n');
s[i]='\0';
i=0;
while(s[i]!='\0')
{
if(s[i]=='(')
{
while(s[i]!=')')
++i;
}
if(s[i]!=')')
printf("%c",s[i]);
i++;
}
return 0;
}
INPUT/OUTPUT:
Enter the string:amhjdg (dshjg)(dbh)hjdv dgfv (a)
OUTPUT: amhjdg hjdv dgfv
No comments:
Post a Comment