In C, if i have the following code incomplete code : #include <stdio.h> #include
ID: 3727196 • Letter: I
Question
In C, if i have the following code incomplete code :
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
extern int pop();
extern void push(int);
int main(int argc, char * argv[])
{
int ch;
while ((ch = getchar()) != EOF) {
if (!(isalpha(ch) || ch == '>' || ch == '<' || ch == '/'))
continue;
//
}
exit(0);
}
where after "continue" the rest of the code goes and pop() and push(int) are the Stack operations.
If a user enters input in the XML form such as : <a></a>.... where <a> is the starting tag and </a> is the ending tag, then please write the rest of the code that checks if the "<" is followed by a "/" then it recogonizes it as a end tag and then uses the pop() function. Otherwise it recgonizes it as a start tag and uses push(x) function to add the element "x" onto the stack. Suppose the stack.c has the function pop() and push(x) function.
Explanation / Answer
Correct Code which you want.... if your desire implementation was different then comment for this.
i use int flag for solve this problem if starting tag found flag will be one and if closing found flag will be 2 at char = '>'