Groups | Search | Server Info | Login | Register
Groups > comp.lang.java.programmer > #5535
| From | Ney André de Mello Zunino <zunino@softplan.com.br> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: The greeting code in Java |
| Date | 2011-06-22 15:55 -0300 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <ittdqf$v3n$1@speranza.aioe.org> (permalink) |
| References | <f61fee62-589e-4ad1-a9ef-a54e2b589e5b@s9g2000yqm.googlegroups.com> <969kscFjduU6@mid.individual.net> |
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 | Next — Previous in thread | Find similar
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