Hi -
I know that this has been somewhat discussed in a couple of threads, but I haven't seen anything with an actual answer.
What would the design or pseudocode look like?
Write a program that checks HTML files to determine whether the embedded XHTML tags are balanced. The program will read from an executable file provided by the user and print an analysis of the file to the screen. The sequence of tags in the file will be echoed to the output; any other text in the file is to be ignored. If there is a tag balancing error or the program reaches the end of the file while in the middle of a tag, the program must quit and print an error message. If the end of file is reached without any errors, print a message to that effect.
The program must use command line arguments. At the command line the user must enter (in this order): the name of the executable file, the name of the HTML file to be checked.
The program must store the tags read in from the file in a queue and then use a stack to check the balancing. Since you're required to use both a queue and a stack, you MUST write the functions, enqueue() and dequeue() as well as push() and pop().
A stack can be used to check for balancing by pushing each start tag onto the stack. When an end tag is encountered, a start tag is popped off the stack and the two are compared. If the tags are matching start/end tags, processing continues; otherwise, the program should issue an error message and stop. You MUST close any file that you have opened.