this code gets input like this
but in c++ std::cin will get input after space or \n
So how do I make ruby get input like std::cin
I am new to ruby and can not find the answer on google so help would be appreciated thanks

You could always just get the entire line and split it up by spaces:

line = gets
return unless line
line.chomp.split(/\s+/).each do |token|
   puts "Token: #{token}"

which will give you something like:

1 2 3 4 5 # this is the input
Token: 1
Token: 2
Token: 3
Token: 4
Token: 5
This question has already been answered. Start a new discussion instead.