C++ string imput

Posted on 2003-02-25
Medium Priority
Last Modified: 2010-04-17
I'm making a program which requires people to inmput a string and I wasn't sure if it was possible to make the program look for specific words like what, is, pi, ect...
If it is what kind of code would i use?
Question by:Durion
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
  • 2

Accepted Solution

tinchos earned 100 total points
ID: 8021740
if i were you, i would read all the words and then parse it

#include <string>

bool done = false;

while( !done )
  std::string input;

  input << std::cin;

  switch( input )
     case "What" : doSomething(); break;
     case "pi" : doSomethingElse(); break;
     case "is" : doSomethingElse2(); break;
  // set done = true when done parsing


Author Comment

ID: 8021816
thanks a lot!!!

Expert Comment

ID: 8021838
ok, glad it helped

accept the comment as an answer and we're done


Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

752 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