when i ran it it just exited after getting a value.
what I see:
your first loop gets 2 numbers.
if both are negative, it exits the loop. if not, it goes again.
however they are used (illegally, since array sizes CANNOT be variables) to craft an array where the size can't be negative.
it looks like it should say
do
cout << "prompt stuff\n";
cin >> corridas >> pilotos;
while(corridas <1 || pilotos <1); //must be 1 or more NOTE THE OR, AND is incorrect here!
also note that crridas & pilotos are LOCAL TO THE LOOP and should not continue to exist outside the loop. so the values you read in are discarded! Declare them outside the loop at main's scope.
{
int x;
}//x is destroyed here, it only exists in the scope (set of braces) where it was created.
note: see how I cleaned up the if/break + infinite loop just by changing the loop style and its condition? See how that is cleaner? Your idea is OK (your logic is the problem, not the idea) but it is clunky.
If the size of the array is not a fixed value that is known beforehand, i.e. at compile-time, and if you are programming in C++ (not just C), then it's probably the best to use astd::vector.
1 2 3 4 5 6 7 8
void foo(const size_t n)
{
std::vector<int> vec(n);
for (size_t i = 0; i < n; ++i)
{
vec[n] = /*whatever*/;
}
}