Computer Science Canada Stupid Nub Question |
Author: | eNc [ Tue Jun 15, 2004 9:38 pm ] | ||
Post subject: | Stupid Nub Question | ||
Umm is it possible to write a statement in C++ similar to a get statement in Turing where you can actually get a sentence or a word from the user ? eg..
like cause i can't get more than 1 char from the "user" --Thanks |
Author: | Catalyst [ Tue Jun 15, 2004 9:41 pm ] | ||||
Post subject: | |||||
or for multiple words
|
Author: | wtd [ Tue Jun 15, 2004 10:00 pm ] | ||||||||||||||||||||||||||
Post subject: | Re: Stupid Nub Question | ||||||||||||||||||||||||||
eNc wrote: Umm is it possible to write a statement in C++ similar to
a get statement in Turing where you can actually get a sentence or a word from the user ? eg..
like cause i can't get more than 1 char from the "user" --Thanks Start out with the basic framework of a C++ program:
Then you need the string library and the iostream library so you can deal with strings and input and output.
Now, you'll want an equivalent for:
And then an equivalent for:
And an equivalent for:
And just for fun, in Ruby ![]()
And Python...
Perl...
O'Caml
|
Author: | wtd [ Tue Jun 15, 2004 10:04 pm ] | ||||||
Post subject: | |||||||
Catalyst wrote:
or for multiple words
Don't use char arrays when you should use std::string.
|
Author: | Catalyst [ Tue Jun 15, 2004 10:20 pm ] |
Post subject: | |
havent used getline much (or at all), wasnt aware it took std::strings |
Author: | eNc [ Tue Jun 15, 2004 11:10 pm ] |
Post subject: | |
wtd holy you kno so many languages! |
Author: | wtd [ Tue Jun 15, 2004 11:49 pm ] | ||||||
Post subject: | |||||||
Well, there are a few I didn't list there, and my knowledge of O'Caml is just starting to come together. Yet it's an incredibly nifty language. For instance:
Or a more practical example. The Printf module has a fprintf function similar to C's. But what if, for writing error messages out I don't want to always write:
I can instead write:
|
Author: | eNc [ Wed Jun 16, 2004 6:39 am ] |
Post subject: | |
wewt !!! What job do you work ? How long did it take you to learn those ![]() |