How can I design input without knowing in advance how many values will be entered? <p>I want to input based on how many values a user inputs, without expecting an exact number of values. </p> <p>In my program I want user to input integer(s) but the problem is that I want to allow the user to either input one or two space separated integers.</p> <p>So,if user enters two space separated integers,they should get stored in variables a and b,and if he enters just one number before pressing enter then it should get stored in a,and the program should proceed further without waiting for the second number.</p> <p>What is the best way to do that?</p>