I am new to C++ and am writing a program that will call other functions. I keep getting an error for a undeclared identifier for "vowel" in this section of code. Can anyone help?
#include <iostream>
#include <iomanip>
using namespace std;
void generate_random_vowel(char &vowel);
int main ()
{
char vowel;
//call test function
generate_random_vowel(vowel);
}
void generate_random_vowel (char &vowel) //function for generate_random_vowel. Outputs a random vowel
{
srand(22); //number to seed the rand
//random numbers 1 - 5, there are 6 vowels (including sometimes Y). Start with case 0.
switch (vowel) //will pull a case at random for a random vowel. Written in this fashion for a direct cout and to save space
{
case0:std::cout<<'A'; break; //make sure break is included
case1:std::cout<<'E'; break; //make sure break is included
case2:std::cout<<'I'; break; //make sure break is included
case3:std::cout<<'O'; break; //make sure break is included
case4:std::cout<<'U'; break; //make sure break is included
case5:std::cout<<'Y'; break; //make sure break is included
default:std::cout<<"Sorry, try again"; break; //error with the random pull, advising the user to try again
}
}