Basically, I have this code that has three separate functions, but it's all under the int main(). What I want to know is how I can separate the three functions without receiving syntax errors and losing all my code?
I'll give you one tip, you should use #define variables for the dimension arrays.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#define ROWS 6
#define COLS 6
int array[ROWS][COLS];
int main(){
//somewhere later in the code
for(int i=0; i<COLS; ++i){
for(int j=0; j<ROWS; ++j){
//do whatever
}
}
this way you have only one point of control, which is good design.
theoretically, const ints can work as well, but from what I understand it wouldn't be compiler portable, as some compilers accept consts int array dimensions and some don't. so just use the #define to macro your dimensions.
What compilers don't? every book i've read suggested using constants, and i don't see a reason not too ( unless of course the compiler didnt except it )
When I did this on it's own function, it kept repeating without going to the next one (in this case the dice roll sequence).
1 2 3 4 5 6 7 8 9 10 11 12 13 14
int main()
{
{
srand (time(NULL));
}
while (retry)
{
//Ask user to input the seed value
unsignedshort seed;
cout << "Enter the seed";
cin >> seed;
srand(seed);
just a couple of questions to the OP. do you know how to properly work with functions? and why did you put random brackets around the time seed to random?