lundi 19 novembre 2018

How to generate an 8-bit random number in C>

int main(){

    uint8_t *wdata = NULL;
    wdata = calloc(5, sizeof(uint8_t));

    for (int j =0;j<5;j++){

        wdata[j] = rand();

    }

}

The rand() function generates 16 bits of data. How do I generate 8 bits of random values? Do I need to use a custom function for the same?




Aucun commentaire:

Enregistrer un commentaire