Solved

how to use "getline"?

Posted on 1998-10-24
5
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

717 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