void generate_number(){
srand(time(0));
int generated_number = rand()%101;
};
so i've created a function just to create numbers whenever i'd want to.But the variable is non-reachable from other functions and there is probably another problem either bcs i've created it as "int generated_number = ..."
i'd like to use this "generated number". But im confused. lets say there is a main function
int main()
{
generate_number();
cout << ......(preferably the generated number but different everytime) * 5;
}
I've tried to use pass by value but it didnt work. How can i use this function and it's variable whenever i'd like to?
Aucun commentaire:
Enregistrer un commentaire