Problem with functions

Hi I made this program, and i was having trouble dividing it into 2 functions.

One called user_input(), and the other one user_output().

Can anyone help me?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <cstdlib>
#include <ctime>


using namespace std;


const int size = 20;
int numPlayers[size];
int quickNum[size];
int length[size];

int main ()
{

cout<<"How many players will be playing?"<<endl;
cin>>numPlayers[size];
for(int a=0; a<numPlayers[size]; a++){
cout<<"What is your name player # "<<a+1<<"?"<<endl;
string name;
cin>>name;
cout<<"Hello "<<name<<" how many quick picks will u be playing today?"<<endl;
cin>>quickNum[size];
for(int b=0; b<quickNum[size]; b++){
cout<<"What should the length of quick pick # "<<b+1<<" be"<<endl;
cin>>length[size];
cout<<"Your numbers are: ";
srand((unsigned)time(0));
int random_integer;
for(int index=0; index<length[size]; index++){
random_integer = (rand()%99)+1;
cout << random_integer<<" ";
}
cout<<endl;
}
}
}
First get it working as is. You are indexing your arrays with size, which is outside the range of allowable indices.
Line 17 to 27 is input and line 28 to 34 is output but as Hammurabi says get this to work then substitute the 2 functions for the code in main()
Topic archived. No new replies allowed.