I need to generate a random binary number (or decimal and convert it), and store that number in an array, needless to say im lost and would appreciate any help. Thx
SurviBee 0 Newbie Poster
Recommended Answers
Jump to PostAll numbers are stored in binary. Do you mean generate a random number and then save the binary conversion as a string?
Jump to PostThe bitset class lets you work with bits, and you can easily print them too.
#include <bitset> #include <cstdlib> #include <iostream> using namespace std; int main() { for ( int i = 0; i < 10; ++i ) { cout<< bitset<8>( unsigned char( rand() ) ) <<"\n"; …
All 5 Replies
Hamrick 150 Posting Whiz
SurviBee 0 Newbie Poster
Hamrick 150 Posting Whiz
SurviBee 0 Newbie Poster
samtronxindia 0 Newbie Poster
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.