i have to define a variable that i am using in a program but i want the variable to change from int to char.
example
#include <iostream>
#include <cstdlib>
int main()
{
int l=rand();
char x;
std::cout<<"this program makes a random char or number enter n for a number or c if you want a letter\n";
std::cin>>l>>"\n";
if (x="c")
{
char l=rand();
std::cout<<"here is your letter :"<<l<<"\n";
}
else if (x="n")
{
int l=rand();
std::cout<<"here is your number :"<<l<<"\n";
}
}
so i already know there is other problems this was just an example i wrote real quick to show what i meant. i want to make it so that depending on what the user enters it will change l from a char to an int. I don't know if there is something to do this but if there is i would like to know.
Thank You