I am trying to write a file that outputs every possible 16 bit number. I am getting the output in 16 digit hex instead of 16 digit binary. How can I get it in binary. Thank you
FILE * file = fopen("16BitFile.txt", "w"); for(int i=0; i<65536; i++) { fprintf(file, "%016x\n", i); }
std::bitsetmay save you some work of having to roll your own translation code.