Originally Posted by
CommonTater
Since this isn't what I'd call a very clear description your best bet would be to rough out some code, even if it's not working and post it up and we'll see what we can do...
Code:
struct node //STACK
{
char *x;
struct node* next;
};
struct nd //QUEUE
{
char *x;
struct nd* next;
};
void enqueue(QUEUE *head, char *c)
{
QUEUE p;
QUEUE temp;
temp = (queues*) malloc(sizeof(queues));
if(*head==NULL)
{
temp->x = (char*)calloc(strlen(c),sizeof(char));
temp->next = NULL;
*head=temp;
}
else
{
p=*head;
while(p->next!=NULL)
p=p->next;
temp->x =(char*)calloc(strlen(c),sizeof(char));
temp->next = NULL;
p->next = temp;
}
}
void toRPN(STACK *top, char* x, STACK2 *top2)
{
setColor(2);
while(*x!='\0')
{
if(*x=='(')
push(&(*top),*x);
else if(*x==')')
{
while(!isEmpty(*top) && strcmp((*top)->x,"(")!=0)
pop(&(*top));
if(strcmp((*top)->x,"(")==0)
pop(&(*top));
}
else if(isalnum(*x))
{
char temp[5] ="";
char *p = temp;
while(isalnum(*x))
{
*p++ = *x++;
}
*p='\0';
enqueue(&head,temp);
}
...
Is that okay? I modified it with Salem's code already. I got rid of that error but now im getting another one -__-