Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.lang.java.programmer > #5535

Re: The greeting code in Java

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail
From Ney André de Mello Zunino <zunino@softplan.com.br>
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 <ittdqf$v3n$1@speranza.aioe.org> (permalink)
References <f61fee62-589e-4ad1-a9ef-a54e2b589e5b@s9g2000yqm.googlegroups.com> <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

Show key headers only | View raw


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 <iostream>
#include <string>

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

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Find similar


Thread

The greeting code in Java Saeed Amrollahi <amrollahi.saeed@gmail.com> - 2011-06-19 06:05 -0700
  Re: The greeting code in Java rossum <rossum48@coldmail.com> - 2011-06-19 17:36 +0100
    Re: The greeting code in Java Saeed Amrollahi <amrollahi.saeed@gmail.com> - 2011-06-19 12:15 -0700
      Re: The greeting code in Java Martin Gregorie <martin@address-in-sig.invalid> - 2011-06-19 19:46 +0000
        Re: The greeting code in Java Saeed Amrollahi <amrollahi.saeed@gmail.com> - 2011-06-19 22:34 -0700
          Re: The greeting code in Java Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2011-06-23 11:43 +0300
        Re: The greeting code in Java Martin Gregorie <martin@address-in-sig.invalid> - 2011-06-20 10:13 +0000
          Re: The greeting code in Java Michael Wojcik <mwojcik@newsguy.com> - 2011-06-22 09:29 -0400
      Re: The greeting code in Java Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-19 16:00 -0400
      Re: The greeting code in Java Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-19 16:05 -0400
        Re: The greeting code in Java Saeed Amrollahi <amrollahi.saeed@gmail.com> - 2011-06-19 22:40 -0700
      Re: The greeting code in Java rossum <rossum48@coldmail.com> - 2011-06-19 22:28 +0100
  Re: The greeting code in Java Roedy Green <see_website@mindprod.com.invalid> - 2011-06-19 21:14 -0700
  Re: The greeting code in Java Roedy Green <see_website@mindprod.com.invalid> - 2011-06-19 21:23 -0700
  Re: The greeting code in Java blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-06-20 19:20 +0000
    Re: The greeting code in Java Ney André de Mello Zunino <zunino@softplan.com.br> - 2011-06-22 15:55 -0300

csiph-web