User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 391,590 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,663 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 3195 | Replies: 1
Reply
Join Date: Feb 2005
Posts: 3
Reputation: fopah is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
fopah fopah is offline Offline
Newbie Poster

user input into a string

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2004
Posts: 3,449
Reputation: Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light 
Rep Power: 16
Solved Threads: 138
Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: user input into a string

  #2  
Mar 28th, 2005
#include <iostream>
#include <string>

int main()
{
   std::string input;
   std::cout << "Enter a string: ";
   if ( getline(std::cin, input) )
   {
      std::cout << "You entered " << input << std::endl;
   }
   return 0;
}
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C++ Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 11:16 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC