Solved

how to use "getline"?

Posted on 1998-10-24
5
195 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

810 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