From binary to string
I have to convert the binary to string, I tried something, but it didn't work. This is my code (I am not allowed to change the main function!), but I can't understand what's wrong: #include <stdio.h> #include <stdbool.h> #include <math.h> #include <string.h> void decode_bytes(const int rows, bool bytes[rows][8], char string[rows]) { int iteration = 8; for (int j = 0; j < rows; j++) { for (int i = 0; i < iteration; i++) { if (bytes[j][i] == 1) { string[j] += pow(2, iteration - (i + 1)); } } } } int main() { bool bytes2[7][8] = { { 0,1,0,0,1,0,0,0 }, { 0,1,1,0,0,1,0,1 }, { 0,1,1,0,1,1,0,0 }, { 0
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.