First, yes this is a school project. That said, I have a seed, now I need to create a function that will create a byte array of random bits. The input for the function should be the number of requested random bits.

Here's an example:

unsigned char* getRandomBits (int number);

number is number of random bits requested.

Any tips would be appreciated.

Thanks.

Recommended Answers

All 2 Replies

Get a random number modulus 2 to get a bit.

Ok, so I can generate a random number with rand() and then mod 2 to get a random bit. Then get another random number mod 2 for bit two, and so on...

I can do that...

Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.