Select amount of integers

I have a question:
I want to add some amount of numbers and find its average, but the numbers I add will be different, so what command I should use to chose how much integers I want to use?
a.) Ask the user to input how many they want
or
b.) Use std::vector and let them input as many as they want until they input a specific value or something
1
2
3
4
5
6
7
8
9
10
11
12
13
int table[];
const int special=-1;
int sum;
int in;
int n;
int i;
for(i=0;;i++){
cin>>in;
if(in!=special)table[i]=in;
else break;}
for(n=0;n<i;n++)sum+=table[n];
sum/=n;
cout>>sum;
That code at best stomps memory.

Topic archived. No new replies allowed.