Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: =?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?= Newsgroups: comp.lang.java.programmer Subject: Re: The greeting code in Java Date: Wed, 22 Jun 2011 15:55:13 -0300 Organization: Aioe.org NNTP Server Lines: 32 Message-ID: References: <969kscFjduU6@mid.individual.net> NNTP-Posting-Host: w0a+kOOTZATJkk1cT24XDA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20110528 Thunderbird/5.0b1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5535 On 20/06/2011 16:20, blmblm@myrealbox.com wrote: > Um, has anyone else pointed out that these two programs don't do the > same thing? Unless the C++ implemented by GCC is broken, the C++ > program reads a whitespace-delimited string, while the Java program > reads a full line of text. Agreed. An equivalent C++ program to the proposed Java version which reads all input until a \newline\ is found would be something like: *** #include #include int main() { std::cout << "Your name? "; std::string name; std::getline(std::cin, name); std::cout << "Hello, " << name << "!\n"; } *** As a side note, the OP's code unnecessarily included /using/ declarations (names were already used in qualified form) and /endl/ (where '\n' should have sufficed). But I digress. Regards, -- Ney André de Mello Zunino