mercredi 30 mars 2022

I'm trying to build a dice program using C++ it isn't displaying my return [closed]

The code is printing the greeting and all the messages except the number. I need to see what is being generated by my random number generator.

#include <iostream>
#include <cstdlib>
#include <ctime>

void greeting(int pnum){
       if(pnum == 1) {
           std::cout << "Please press \"ENTER\" to roll the die"; 
       }
       else {
            std::cout << "Please press \"ENTER\" to roll the die AGAIN"; 
       }
        std::cin.ignore();
}

int dieroll(void){
    int ran;
    srand(time(NULL));
    ran = rand()%6+1;
    std::cout << "You have rolled :" << std::endl;
    return ran;
}

int main(void){
    int counter, firstdie, ran;
    char firststart;

    do {
        greeting(1);
        firstdie = dieroll();
    }
 
    while (ran > 0);
    {
        return ran;
    }
    
    std::cin.ignore();
    return 0;
}

I'm a beginner so i'm unsure where to start trouble shooting. I'm looking into making local variables.




Aucun commentaire:

Enregistrer un commentaire