Gray - Binary conversion

Hi there! so i'm trying to convert 16 bit in gray code to binary, i did it, but if the program recieves only a 4 bit gray number, for example, it considers the rest of the char array as 0. How can i fix it?? Here's the code:

Here's the code

Posting code at a pixel height of 0 is silly.