Solved

how to use "getline"?

Posted on 1998-10-24
5
186 Views
Last Modified: 2010-04-02
how to use the function "getline" in order to get a string input from keyboard?

moreover, how to change an infix math expression to postfix by using stack?
e.g. 1 + 2 * 3
will be
1 2 3 * +

tks!!
0
Comment
Question by:chuyan
  • 3
5 Comments
 
LVL 1

Expert Comment

by:newexpert
ID: 1176000
cin.getline(char *yourbuf, int max_length_allowed, char line_terminator_to_look_for);

If you use the latest STL, then it's simply cin.getline(string your_string, char terminator);
0
 

Author Comment

by:chuyan
ID: 1176001
oh yup! tks!!
0
 

Author Comment

by:chuyan
ID: 1176002
Edited text of question
0
 
LVL 22

Accepted Solution

by:
nietod earned 20 total points
ID: 1176003
>> how to change an infix math expression to postfix by using stack?
We can provided limited help on school assignments.  We can answer questions, like you might ask your teacher and we can review your work and provides suggetions  and criticism.

But I think I can say this much.  You will have a recursive procedure that parses the expression.  When it comes to the left operand.  It places it on the stack.  When it comes to the operator, it stores it temporarily in a local variable and calls itself to to process the rest of the expression.  When it returns it places the operator on the stack and then returns to the caller.

Give it a try.
0
 

Author Comment

by:chuyan
ID: 1176004
tks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now