-1

How can I convert a uint8_t array to a char array or string in C?

uint8_t array[10];
Eric
  • 23
  • 4
  • string and char array are two different things. – OldProgrammer Mar 18 '22 at 17:31
  • Show some more code and tell us what you want to do with the char array or string once "converted". – Jabberwocky Mar 18 '22 at 17:32
  • `uint8_t` is a `typedef` alias for `unsigned char`, no "conversion" is necessary; it is a matter of interpretation. In C a string is not a data-type. It is a sequence of characters terminated with `'\0'`. A `char` array is a "container" that can hold a string. In short, your question is ambiguous. What are you trying to achieve? – Clifford Mar 18 '22 at 20:19

1 Answers1

0

You just have to cast it, assuming you system defines char as 8 bits:

char *string = (char*)array;
SGeorgiades
  • 1,771
  • 1
  • 11
  • 11