www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/12/05/02:35:08

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: Thomas Hansen <thomas DOT hansenNOSPAMORILLSUEYOURXXX AT adramatch DOT com>
Newsgroups: comp.os.msdos.djgpp,comp.lang.c++,alt.comp.lang.learn.c-c++
Subject: Re: More than one letter input
Date: Wed, 05 Dec 2001 08:21:34 +0100
Organization: adra match asa
Lines: 38
Message-ID: <6lir0uk5hsktmolpboejm5mtpqm120da9q@4ax.com>
References: <91509768 DOT 0112031721 DOT 1481a4ee AT posting DOT google DOT com>
NNTP-Posting-Host: 193.71.234.202
Mime-Version: 1.0
X-Trace: oslo-nntp.eunet.no 1007536920 8079 193.71.234.202 (5 Dec 2001 07:22:00 GMT)
X-Complaints-To: abuse AT KPNQwest DOT no
NNTP-Posting-Date: 5 Dec 2001 07:22:00 GMT
X-Newsreader: Forte Agent 1.8/32.553
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On 3 Dec 2001 17:21:44 -0800, there came a drop of sanity from
person0000000000 AT yahoo DOT com (Person) containing:

>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?
>
>--Person
#include <iostream> // Standard header inclusion
main()
{
   using namespace std;
  string name; // Use string and not char
  int x;
  cout << "Name: ";
  cin >> name;
  cout << "Hello, " << name << "\n";
}
-- 
"FOOT-AND-MOUTH BELIEVED TO BE FIRST VIRUS
UNABLE TO SPREAD THROUGH MICROSOFT OUTLOOK"

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019