user input into a string

Reply

Join Date: Feb 2005
Posts: 3
Reputation: fopah is an unknown quantity at this point 
Solved Threads: 0
fopah fopah is offline Offline
Newbie Poster

user input into a string

 
0
  #1
Mar 28th, 2005
i need the user to input a todolist type thing it uses strings to save the items.
what i need to know is how to have the user input a string with the getline function any help would be much appreciated
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,314
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 229
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: user input into a string

 
0
  #2
Mar 28th, 2005
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main()
  5. {
  6. std::string input;
  7. std::cout << "Enter a string: ";
  8. if ( getline(std::cin, input) )
  9. {
  10. std::cout << "You entered " << input << std::endl;
  11. }
  12. return 0;
  13. }
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC