mercredi 26 août 2015

How to pick assign something to something out of 2 in C?

so i have got a struct that goes:

enum input_result get_human_player(struct player* human)
{
    char playerName[NAMELEN];
    printf("What is your name? ");
    fgets(playerName, NAMELEN, stdin);
    strcpy((*human).name, playerName);

    (*human).type = HUMAN;
    (*human).thiscolor = C_WHITE;
    (*human).counters = 0;

    return FAILURE;
}

how do i make it so it randomly assigns it to either C_WHITE or C_RED with a 50/50 chance?




Aucun commentaire:

Enregistrer un commentaire