[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Input using stdin

Nikhil Warade

3/12/2008 7:03:00 AM

How can I give input to a program using STDIN
Suppose I want the program to take the value x=10
On some other site i found it as STDIN.read,but its not working.
--
Posted via http://www.ruby-....

4 Answers

Friedrich

3/12/2008 7:24:00 AM

0

Nikhil Warade <newarade47@gmail.com> writes:

> How can I give input to a program using STDIN
> Suppose I want the program to take the value x=10
> On some other site i found it as STDIN.read,but its not working.
>

print("Give me a string ");
STDOUT.flush
a_string = gets
print("You gave me '#{a_string}'")

Regards
Friedrich

--
Please remove just-for-news- to reply via e-mail.

Nikhil Warade

3/12/2008 7:37:00 AM

0

Friedrich Dominicus wrote:
> Nikhil Warade <newarade47@gmail.com> writes:
>
>> How can I give input to a program using STDIN
>> Suppose I want the program to take the value x=10
>> On some other site i found it as STDIN.read,but its not working.
>>
>
> print("Give me a string ");
> STDOUT.flush
> a_string = gets
> print("You gave me '#{a_string}'")
>
> Regards
> Friedrich

Please check http://codegolf.c... where we need to input using
STDIN
You don't seem to have used STDIN
--
Posted via http://www.ruby-....

Friedrich

3/12/2008 8:06:00 AM

0

Nikhil Warade <newarade47@gmail.com> writes:

> Friedrich Dominicus wrote:
>> Nikhil Warade <newarade47@gmail.com> writes:
>>
>>> How can I give input to a program using STDIN
>>> Suppose I want the program to take the value x=10
>>> On some other site i found it as STDIN.read,but its not working.
>>>
>>
>> print("Give me a string ");
>> STDOUT.flush
>> a_string = gets
>> print("You gave me '#{a_string}'")
>>
>> Regards
>> Friedrich
>
> Please check http://codegolf.c... where we need to input using
> STDIN
> You don't seem to have used STDIN
gets works on the standard input if you insist you can write
STDIN.gets if that makes you feel better


STDIN.public_methods.sort
=> ["<<", "==", "===", "=~", "__id__", "__send__", "all?", "any?",
"binmode", "class", "clone", "close", "close_read", "close_write",
"closed?", "collect", "detect", "display", "dup", "each", "each_byte",
"each_line", "each_with_index", "entries", "eof", "eof?", "eql?",
"equal?", "extend", "fcntl", "fileno", "find", "find_all", "flush",
"freeze", "frozen?", "fsync", "getc", "gets",
^^^^^^ here is your gets

Friedrich

--
Please remove just-for-news- to reply via e-mail.

Phillip Gawlowski

3/12/2008 8:12:00 AM

0

Nikhil Warade wrote:
> STDIN
> You don't seem to have used STDIN
>
> Please check http://codegolf.c... where we need to input using
http://en.wikipedia.org/wiki/Standard_streams#Standard_input_....