Need to input a series of number in c++ ...

I am looking for a very simple input ... umm , take this example :-
user enters the following :-
3 (enter)
53 61 23 (enter)
now i have stored 53,61,23 at 0,1&2 index of array a.

if user enters following :-
5 (enter)
23 56 21 78 45 (enter)
now i have stored 23,56,21,78,45 at 0,1,2,3,4 index of array a.

Can anybody help me Fast ! Thankyou in advanced .
Try:
1
2
3
4
5
6
7
8
int MyArray[100], i=0;
string Line;
stringstream iss;

getline(cin,Line);
iss << Line;
while(iss.good())
    iss >> MyArray[i++];
Last edited on
I think OP is looking for an array with size defined at runtime by the user. I might recommend just looking into vectors? Makes life much easier
@Stewbond, your code is definatly working but its storing number into an array & i will have to type cast it and i am needing to declare extra header file resulting in decrease of speed of my program & memory . Thankyou still for your code.
@ResidentBiscuit, ok let me see vectors.

But still is there any other or better solution to this ???
resulting in decrease of speed of my program & memory
Your program speed is not affected by this!

If that was the case then we will be using only core language because adding extra files would slow out programs. Not a lot of thing you can do by only that though.

Maybe you need to be more specific of what exactly you want. Others assumed different because maybe you weren't specific enough
Okay , i have got it , thankyou all .
Topic archived. No new replies allowed.