delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mailnull set sender to djgpp-bounces using -f |
From: | person0000000000 AT yahoo DOT com (Person) |
Newsgroups: | comp.os.msdos.djgpp,comp.lang.c++,alt.comp.lang.learn.c-c++ |
Subject: | Re: More than one letter input |
Date: | 4 Dec 2001 09:51:24 -0800 |
Organization: | http://groups.google.com/ |
Lines: | 55 |
Message-ID: | <91509768.0112040951.3efa7849@posting.google.com> |
References: | <91509768 DOT 0112031721 DOT 1481a4ee AT posting DOT google DOT com> <3c0c2755_3 AT mk-nntp-1 DOT news DOT uk DOT worldonline DOT com> |
NNTP-Posting-Host: | 148.233.95.58 |
X-Trace: | posting.google.com 1007488284 11763 127.0.0.1 (4 Dec 2001 17:51:24 GMT) |
X-Complaints-To: | groups-abuse AT google DOT com |
NNTP-Posting-Date: | 4 Dec 2001 17:51:24 GMT |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Ok, thanks a lot! I was using "The Complete C Reference", and another one that I don't know what it is called. They probably say this, but I was to lazy to look for it :) thanks again. "Neil Butterworth" <neil_butterworth AT lineone DOT net> wrote in message news:<3c0c2755_3 AT mk-nntp-1 DOT news DOT uk DOT worldonline DOT com>... > "Person" <person0000000000 AT yahoo DOT com> wrote in message > news: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> > > This is not a standard C++ header file - you want > > #include <iostream> > > > > > main() > > In standard C++, main must return an int. > > > { > > char name; > > int x; > > cout << "Name: "; > > cin >> name; > > cout << "Hello, " << name << "\n"; > > } > > > > It only takes the first letter of the name. > > Because a char is only one letter. You need a string - a sequence of > letters: > > #include <iostream> > #include <string> > > using namespace std; > > int main() { > string name; > cout << "Name: "; > cin >> name; > cout << "Hello, " << name << "\n"; > } > > All this should be covered in any beginners book on C++ - which one are you > using? > > NeilB
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |