I am trying to fill an array with a large number using cin. What I would like to do it take a number like 123,456,789 and put it into someArray[0] = 123, someArray[1] = 456, etc. Can this be done easily?
Printable View
I am trying to fill an array with a large number using cin. What I would like to do it take a number like 123,456,789 and put it into someArray[0] = 123, someArray[1] = 456, etc. Can this be done easily?
Probably. After all, it depends on what exactly you want to do. Are you trying to split by commas?Quote:
Can this be done easily?
guess you could:
1) Take the input as a character string instead of a number.
2) Parse the character string.
3) Convert string to an int before storing in the array.
Quote:
Originally Posted by laserlight
I need some way to seperate either by commas or seperate into 3 digit pieces after the fact.
You could just remove all the non-digit characters from the string, then read in three characters at a time.