Question: Can anyone suggest means of converting a byte array to ASCII in C? Or converting byte array to hex and then to ASCII?

[04/02][Edited]: To rephrase it, I wish to convert bytes to hex and store the converted hex values in a data structure. How should go about it?

Regards,
darkie

Answer: 
Well, if you interpret an integer as a `char` in C, you'll get that ASCII character, as long as it's in range.

```
int i = 97;
char c = i;

printf("The character of %d is %c\n", i, c);

```

Prints:

```
The character of 97 is a

```

Note that no error checking is done - I assume `0 <= i < 128` (ASCII range). 

Otherwise, an array of byte values can be directly interpreted as an ASCII string:

```
char bytes[] = {97, 98, 99, 100, 101, 0};

printf("The string: %s\n", bytes);

```

Prints:

```
The string: abcde

```

Note the last byte: 0, it's required to terminate the string properly. You can use `bytes` as any other C string, copy from it, append it to other strings, traverse it, print it, etc.
Char.s and Int.s are stored in binary in C. And can generally be used in place of each other when working in the ASCII range.

```
int i = 0x61;
char x = i;

fprintf( stdout, "%c", x );

```

that should print 'a' to the screen.