Videos
The code is extremely sloppy, I'm just trying to get my program to work. After half an hour of trying to figure out why 2 strings that were exactly the same in the expression string1==string2 had it evaluating to 0, I tried another compiler. It worked there. Why is GDB doing this?
Whoops you have an infinite loop here
//This creates a LCV for the do loop below and sets it equal to 0.
int y = 0;
//This do loop generates the random number.
do
{
//This generates a random time seed.
srand(time(0));
//This generates a random number between 1 and 99.
ran = rand() % 100;
//This while controls the do loop.
}while (y != 9);
y is initialized to 0 and you are looping while y!=9. And that is just the first error, there might be more.
Bug #2
int z = 1;
//This makes the program only create a random number the first pass through the loop.
if (z < 2)
{
//This runs the random number generator function.
return randomgen();
//This sets the result of the function as the random number.
randnum = randomgen();
//This sets the random number to the current number.
num = randnum;
}
After fixing infinite loop in randomgen(), You are immediately returning...
you have two problems in your code: the first one is that you have infinite loop in randomgen() function the condition in check against y - y != 9 but the value never update
int randomgen()
{
//This creates a variable to store the random number.
int ran;
//This creates a LCV for the do loop below and sets it equal to 0.
int y = 0;
//This do loop generates the random number.
do
{
//This generates a random time seed.
srand(time(0));
//This generates a random number between 1 and 99.
ran = rand() % 100;
//This while controls the do loop.
}while (y != 9);
//This returns the random number for use in the rest of the program.
return ran;
}
and the second one is even if you pass the loop in the function you exit main right away because the call to the function randomgen() is with return
if (z < 2)
{
//This runs the random number generator function.
return randomgen(); <-- **second problome**
//This sets the result of the function as the random number.
randnum = randomgen();
//This sets the random number to the current number.
num = randnum;
}
For whatever reason, I really can't use Visual Studios Code. It says g++ not recognized even after I installed MSYS2 and added it as a path in my environment variables.
I just want to finish an assignment so I can relax for the rest of the week