Name: (15pt) XHTML files consists of regular text and tags enclosed in angle bra
ID: 3573821 • Letter: N
Question
Name: (15pt) XHTML files consists of regular text and tags enclosed in angle brackets, and symbols. Tags are used to identify the structure of a document. Most tags come in pairs: a beginning tag and a closing tag. For example, the tags title and are the beginning and closing tags. There are several such tags including Kh1> In case you need, here is the stack ADT interface, exporting void as the element type #ifndef 3 tac define stack include "genlib.h'' ypedef void stackElementT typedef struc stack CDT stack ADT KADT NewStack (void Stac void Frees tack stack ADT stack. void :sh (stack stac KADT k, tack Element T nt Element. T Pop is ta ckADT stac ti Stac bool Stack IsEmpty istackADT stack bool tack IsFull stackADT stack title StackDepth (stackADT tack int lates GetStack Element. (stackADT stack int index stack Element T nesting iendif stru ctureExplanation / Answer
CODE:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stack>
using namespace std;
void main(int argc , char *argv[]){
char *file = argv[1];
stack <char*> O;
FILE *fp;
fp=fopen(file, "r");
char *a;int nesting_level =0;
a=read_a_tag(fp);
if(string(a).find("/"))
{
printf("Invalid Tag");return;
}
O.push(a);
print_a_tag(a,nesting_level);
while(a!= NULL)
{
if(string(a).find("/"))
{
if(tag_match(O.top(),a))
{
print_a_tag(a,nesting_level);
nesting_level--;
}
else{
printf("Violates nesting structure");
return;
}
}
else{
nesting_level++;
O.push(a);
print_a_tag(a,nesting_level);
}
}
}
OUTLINE:
code assuming your functions are there , so i couldn't keep any outputs.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.