Could someone please explain how to bring a value from a variable in one function to another function. I know that as soon as the function ends that variable's value in the function is cleaned out. But how do I tell it not to do that.
I am trying to bring the int ppl;
value from the candidates function into the votes function. But as you can see it won't do it on its own.
void candidates()
{
int ppl;
cout << "Hello please how many candidates are there?: ";
std::cin >> ppl;
string *cans = new string[ppl];
for (int i = 0; i < ppl; i++)
{
cout << "Please type in the last name of candidate number: " << i + 1 << endl;
cin >> cans[i];cout << endl << endl;
}
for (int a = 0; a < ppl; a++)
{
cout << cans[a] << endl << endl;
}
}
void votes()
{
int *vote = new int[ppl];
// ...
}