TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Joe Wilson
NA
7.8k
433.5k
How can I solve the code below errors in C++?
Oct 14 2014 12:32 PM
Please solve the errors.
This is my code :
#include "stdafx.h"
# include <iostream>
# include <string.h>
# include <stdlib.h>
# include <conio.h>
using namespace std;
int top=-1;
char Stack[25][100]={NULL};
void push(const char *);
const char* pop( );
void postfix_to_infix(constchar *);
int main( )
{
clrscr( );
char Postfix_expression[100]={NULL};
cout<<"\n\n\t Enter the Postfix Expression : ";
cin.getline(Postfix_expression,80);
postfix_to_infix(Postfix_expression);
getch( );
return 0;
}
/*************************************************************************///----------------------------- push(const char) ----------------------///*************************************************************************/void push(constchar *Symbol)
{
if(top==24)
cout<<"Error : Stack is full."<<endl;
else
{
top++;
strcpy(Stack[top],Symbol);
}
}
/*************************************************************************///-------------------------------- pop( ) -----------------------------///*************************************************************************/constchar* pop( )
{
char Symbol[100]={NULL};
if(top==-1)
cout<<"Error : Stack is empty."<<endl;
else
{
strcpy(Symbol,Stack[top]);
strset(Stack[top],NULL);
top--;
}
return Symbol;
}
/*************************************************************************///--------------------- postfix_to_infix(const char *) ----------------///*************************************************************************/void postfix_to_infix(constchar *Postfix)
{
char Infix_expression[100]={NULL};
char Postfix_expression[100]={NULL};
strcpy(Postfix_expression,Postfix);
strcat(Postfix_expression,"=");
int count=0;
char Symbol_scanned[5]={NULL};
do
{
Symbol_scanned[0]=Postfix_expression[count];
if(Symbol_scanned[0]=='/' || Symbol_scanned[0]=='*' ||
Symbol_scanned[0]=='-' || Symbol_scanned[0]=='+' ||
Symbol_scanned[0]=='^' )
{
char Value_1[100]={NULL};
char Value_2[100]={NULL};
char Result[100]={NULL};
strcpy(Value_1,pop( ));
strcpy(Value_2,pop( ));
if(Infix_expression[(count+1)]!='=')
strcpy(Result,"(");
strcat(Result,Value_2);
strcat(Result,Symbol_scanned);
strcat(Result,Value_1);
if(Infix_expression[(count+1)]!='=')
strcat(Result,")");
push(Result);
}
else
push(Symbol_scanned);
count++;
}
while(Postfix_expression[count]!='=');
strset(Infix_expression,NULL);
strcpy(Infix_expression,pop( ));
cout<<"\n\n\t Infix Expression is : "<<Infix_expression;
}
Reply
Answers (
0
)
C# console app..need multiple copies executing simultaneousl
BOF and EOF Not Supported in C sharp