Solved

how to use "getline"?

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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 pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

708 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

13 Experts available now in Live!

Get 1:1 Help Now