March 30, 2008 at 9:25 am #2086PrinceParticipantHiya,
I’m very new to “C” and am really struggling with an Assignment I have been set. I live in a very rural area and finding any help or extra Tutoring has been impossible, I have been recomended this Forum as I’m in serious danger of failing my entire Degree unless I can find some help.
The Assignment is as follows.
“A mark up language gives structure to a Document by using Tags. The Tags say what parts of the document are Titles, Headings, Bullet points etc. Every “on” Tag <...> (eg
) needs a closing “Off” Tag .
Every “off” angle bracket must pair a corresponding “on” bracket <...> that precedes it. At any place in our mark up language text we can either place an “on” Tag, or we can place the “Off” Tag corresponding to the last not yet paired on Tag. Every “on” Tag must be followed sooner or later by it’s corresponding “off” Tag.
Write a C Program using only stdio.h library which diagnoses whether a text typed on one single line is correct in terms of tags or contains mistakes; In the later case the first mistake made in the typed text should be diagnosed. any Tag names are acceptable.”
I’ve been told that I may need “push”, “Pop, and “Stack”?
I’m not asking for the complete Code, I want to understand what has been written, and to submit my own work but I need Help. Any help, pointers or advice would really be appreciated a great deal.
Thank you for your time.
April 28, 2008 at 8:31 am #3371Priyansh AgrawalParticipant
as I know, “push” and “pop” are assembler-commands.
To solve this problem I recommend recursion.
I don’t know if you know what this is, so I’ll explain it shortly:
Recursion is when a function calls itself. So for each call in a call the local variables of the function are pushed on the stack. When the function ends, the variables are removed from the stack.
So you could write a function which is called when the beginning-tag starts. And for each further beginning-tag it calls itself.
In c you will need the string-functions in
like strcmp, strncmp, … to compare the actual string-strip with “<" or "" I think the solution in C cannot be done by a “beginner”. You should know about arrays, pointers, string-functions, etc. When do you need the coding (deadline) ?
May 12, 2008 at 5:22 am #3372AdetutuParticipant
This is not a big problem. One way is suggested to use recursion. Another way is that you can make your own Stack.
Push and pop are the operations of a Stack. When you insert a value in stack it is push and when you fetch the value from stack it is pop. the basic concept of a stack is First in Last out.
Please don’t say that you can not make a program of these operation. If you are doing such programming then you must aware about stack.
Another thing you would need is File handling in case you use real mark up files. For mark up language, You can see any web page. Basi markup language is HTML.
Feel free to revert back if still has confusion.
- You must be logged in to reply to this topic.