Header Ads

Learn Together, Stay Connected.

HTML Parser


Sample input: 

Sample output:




 #include<stdio.h>
#include<string.h>

void parser(char *string)
{
int in=0;
int index=0,i;

for(i=0;i<strlen(string);i++)
{
if(string[i]=='<')
{
in=0;
continue;
}
else if(string[i]=='>')
{
in=1;
continue;
}

if(in)
{
string[index]=string[i];
index++;
}
}
string[index]='\0';
while(string[0]==' ')
{
for(i=0;i<strlen(string);i++)
{
string[i]=string[i+1];
}
}
while(string[strlen(string)-1]==' ')
{
string[strlen(string)-1]='\0';
}

}


int main()
{
char string[50];

scanf("%[^\n]s",string);

// printf("%s\n",string);

parser(string);

printf("~~%s~~\n",string);

return 0;
}

No comments

Theme images by Dizzo. Powered by Blogger.