guys im using reverse polish notation in link list my problem is every time i enter the OPERATOR (+) it will add and that operator display as '0' im having trouble in that operator i need to display it as blank >_< help me guys
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#define p printf
#define s scanf
#include<conio.h>
#include<windows.h>
int number;
char choice;
char operators;
char str[20];
struct node
{
int data;
struct node *link;
};typedef struct node *nodepointer;
void insertfront(nodepointer &head,int number)
{
nodepointer newnode;
newnode=(nodepointer)malloc(sizeof(struct node));
newnode->data=number;
newnode->link=head;
head=newnode;
}
void deletefront(nodepointer &head)
{
nodepointer temp;
if(head==NULL)
{
p("\nNothing to delete");
}
else if(head!=NULL)
{
temp=head;
head=temp->link;
free(temp);
}
}
void display(nodepointer top)
{
int index=1;
if(top==NULL)
{
p("\nNothing to display");
}
else if(top!=NULL)
{
while(top->link!=NULL)
{
if(strcmp(str,"+")==0)
{

}
p("%i\n",top->data);
top=top->link;
}
if(strcmp(str,"+")==0)
{
}
p("%i",top->data);
}
}
void pop_add(nodepointer top)
{
nodepointer after;
nodepointer before;
if(top==NULL || top->link==NULL)
{
p("List is empty or must have two operands first before inserting operator...");
getch();
}
else
{
before=NULL;
after=top;
while(after->link!=NULL)
{
before=after;
after=after->link;
}
p("\n\n\Before is %i",before->data);
before->data=before->data+after->data;
before->link=NULL;
p("\n\n\After is %i",after->data);
}
}
main()
{
nodepointer top;
top=NULL;
do
{
system("cls");
display(top);
p("\n[1]Push");
p("\nKey choice: ");
fflush(stdin);
s("%c",&choice);
switch(choice)
{
case '1':
p("\nEnter number: ");
fflush(stdin);
gets(str);
number=atoi(str);
if(strcmpi(str,"+")==0)
{
pop_add(top);
}
insertfront(top,number);
break;
}
}while(1==1);
system("pause");
}

You've been here for a long time already yet you still didn't put the code between

tags
the reasons WHY you should do this is that it preserves the indentation for easier reading and puts lines of code that help us point out a particular line to comment on

Did you compile the code??
>> if(strcmpi(str,"+")==0)
you have a syntax error here

now for your problem

every time i enter the OPERATOR (+) it will add and that operator display as '0' im having trouble in that operator i need to display it as blank >_< help me guys

display a space using printf(" "); instead of 0...
Though I think you did not ask what you intended to ask here
post what you need in detail here by showing us the desired output or maybe the statement/s involved here
be very detailed when you ask a question

also read the following articles from the links:
Things to avoid in C/C++
gets()
fflush(stdin)
system("pause")

commented: right +0

Zero sorry idk how.but my point is i convert char to int that is my str to number so i can insert + / * operators.ok now my problem is everytime i enter the operator and it always display 0 ..i want to remove that 0 or everytime i will insert + / * the value of operator '0' will not display in the list thats my point.

For example i insert this number
1 2 3 4 and the last part is + operator and it will display as this

0--(zero)
4
3
2
1
this zero refer to an operator value because i convert char to int and my display is %i so operator will also include.i want to exclude this 0 because im getting trouble in my link list

In order to display it like this:

printf("this is right");

you need to type it similar to this

printf("this is right");

as for the problem when you detect that the input is an operator exclude it from being passed from the linked list, this could be solved by using if else statements

HOW???i use it many times does not work

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.