I have a string in binary and I need to convert it to hex. (Obvious right?)
What I'm trying to do is this:
Both out and string are defined as unsigned char[20]Code:for (z = 0; z < 20; z++) sprintf(string, "%02x", out[z]);
Now, I know that hex characters take two bytes, so I also tried
Where y is initialized to 0. I keep getting damage after normal block errors. I thought it was becuase I was overwriting memory so I increased the size of string to 200, which should be MORE than enough room, but I get the same error. Any suggestions?Code:for (z = 0; z < 20; z++) y += sprintf(string+y, "%02x", out[z]);



LinkBack URL
About LinkBacks


