delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
From: | "Mike Wahler" <mkwahler AT ix DOT netcom DOT com> |
Newsgroups: | comp.os.msdos.djgpp,comp.lang.c++,alt.comp.lang.learn.c-c++ |
Subject: | Re: More than one letter input |
Date: | Mon, 3 Dec 2001 17:38:54 -0800 |
Organization: | MindSpring Enterprises |
Lines: | 41 |
Message-ID: | <9uh90f$rd5$1@slb4.atl.mindspring.net> |
References: | <91509768 DOT 0112031721 DOT 1481a4ee AT posting DOT google DOT com> |
NNTP-Posting-Host: | 3f.32.61.ac |
X-Server-Date: | 4 Dec 2001 01:30:55 GMT |
X-Newsreader: | Microsoft Outlook Express 4.72.2106.4 |
X-MimeOLE: | Produced By Microsoft MimeOLE V4.72.2106.4 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Person wrote in message <91509768 DOT 0112031721 DOT 1481a4ee AT posting DOT google DOT com>... >How can I get input for more than one letter (a whole word)?? >I want to make a simple program that asks you for your name, and then >shows it on the screen. > >This is what I have so far: > > #include <iostream.h> > > main() > { > char name; > int x; > cout << "Name: "; > cin >> name; > cout << "Hello, " << name << "\n"; > } > >It only takes the first letter of the name. > >Can someone help me with this please? #include <iostream> #include <string> int main() { std::string name; std::cout << "Please enter your name: "; std::getline(std::cin, name); std::cout << "Hello, " << name << std::endl; return 0; } -Mike > >--Person
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |