Hi,
I'm new to Visual C++, and this may seem like a stupid question... I'm trying to create a game, that will generate an array with random numbers, and print a different array 6 times. I got it to generate random numbers and store them into the array, but when I try to execute it 6 times to print six different arrays, it prints them all the same. Here is the relevant code:
for (int i = 1; i <= 6; i++) {
Console::Write(S"Game "
;
Console::Write(i);
Console::WriteLine(S":"
;
Console::WriteLine(S"-------"
;
int * pwNum = new int[];
PowerGen * pw = new PowerGen();
pwNum = pw->getNum();
for (int x = 0; x < 6; x++) {
Console::Write(pwNum[x]);
Console::Write(S", "
;
}
Console::WriteLine();
Console::WriteLine();
delete pwNum;
delete pw;
}
As you can see, I've tried to delete the pointers so that a new array with different numbers is initialised each time, but it won't work.
Does anyone have any ideas on how to fix this?
Thanks,
Jerry ;o)
I'm new to Visual C++, and this may seem like a stupid question... I'm trying to create a game, that will generate an array with random numbers, and print a different array 6 times. I got it to generate random numbers and store them into the array, but when I try to execute it 6 times to print six different arrays, it prints them all the same. Here is the relevant code:
for (int i = 1; i <= 6; i++) {
Console::Write(S"Game "
Console::Write(i);
Console::WriteLine(S":"
Console::WriteLine(S"-------"
int * pwNum = new int[];
PowerGen * pw = new PowerGen();
pwNum = pw->getNum();
for (int x = 0; x < 6; x++) {
Console::Write(pwNum[x]);
Console::Write(S", "
}
Console::WriteLine();
Console::WriteLine();
delete pwNum;
delete pw;
}
As you can see, I've tried to delete the pointers so that a new array with different numbers is initialised each time, but it won't work.
Does anyone have any ideas on how to fix this?
Thanks,
Jerry ;o)