delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/09/23/17:13:52

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Message-ID: <3C0C2775.BF99D0A6@sensor.com>
From: Ron Natalie <ron AT sensor DOT com>
Organization: Sensor Systems
X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U)
X-Accept-Language: en,pdf
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp,comp.lang.c++,alt.comp.lang.learn.c-c++
Subject: Re: More than one letter input
References: <91509768 DOT 0112031721 DOT 1481a4ee AT posting DOT google DOT com>
Lines: 23
X-Complaints-To: abuse AT usenetserver DOT com
X-Abuse-Info: Please be sure to forward a copy of ALL headers
X-Abuse-Info: Otherwise we will be unable to process your complaint properly.
NNTP-Posting-Date: Mon, 03 Dec 2001 20:22:57 EST
Date: Mon, 03 Dec 2001 20:31:33 -0500
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com


Person wrote:
>
> 
> It only takes the first letter of the name.

That's because char is only big enough to hold one letter.
Furthermore, you're lucky you got that far (your program is
non-standard.

If you want to read a string, use a string type.

#include <iostream>
#include <string>
using namespace std;

int main() {
   string name;
   cout << "Name:  ";
   cin >> name;
   cout < "Hello, " << name << "\n";
}

- Raw text -


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