I am trying to print the value of each character in a string in this format:
Code 2 in set 0 has value: 41 42
Code 6 in set 0 has value: 41 42 43 44 45 46
I am trying to do this by:
printf("Code %d in set %d has value: %.*s\n", ndx, set, getCode(cs[set],ndx).size, getCode(cs[set],ndx).data);
But when I do this it prints the characters associated with the value rather than the value itself. How should I go about printing the data in the format specified?
You’re printing your array as a string. Instead loop through each character and print its decimal value: