I need a way to read input 1 number at a time from a string of 500-1000 numbers.
cin would just give me the entire string, so what do I use?
I need a way to read input 1 number at a time from a string of 500-1000 numbers.
cin would just give me the entire string, so what do I use?
Use cin to input whole string and then index it to handle one number at time. You can access the individual number Str[0], Str[1], and so on...
Making error is human, but for messing things thoroughly it takes a computer
I assume you are looking to read in 10 base numbers and not binary. If this is correct, then how is the "string" organized? Is there a defined separator? Are they all just bunched together(no spaces)? If so, are you just looking for the range of 0 to 9? If not, how do you intend to separate the individual numbers?
My best guess on this would be to read in the string of numbers as an array of char's and then convert them to int's and place them in an int array using a loop based on the total count. Maybe clarify your need, let me know if this plan of action will work for you, and I can help you get started.
David
One Ring to rule them all, One Ring to find them,
One Ring to bring them all and in the darkness bind them
In the Land of Mordor where the Shadows lie.
I believe cin.get would work, assuming no whitespace between characters.