Search anything:

Convert uint8_t* to char* in C++


Internship at OpenGenus

Get this book -> Problems on Array: For Interviews and Competitive Programming

In this article, we have presented how to convert an array of uint8_t (uint8_t*) to an array of char (char*).

Convert uint8_t * to char * in C

uint8_t and char both are of size 8 bits. Moreover, uint8_t is a typedef for char and hence, there will be no loss in conversion if an uint8_t variable is casted to become a char.

uint8_t input = 12;
char input2 = (char) input;

If we are dealing with an array or vector of uint8_t, the process is similar. Just cast the vector to char*.

uint8_t* input = {12, 1, 65, 90};
char* input2 = (char *) input;

Following is the complete C++ converting uint8_t* to char*:

#include <stdlib.h>

int main() {
  uint8_t* input = {12, 1, 65, 90};
  char* input2 = (char *) input;
  return 0;

With this article at OpenGenus, you must have the complete idea of how to convert uint8_t* to char*.

Geoffrey Ziskovin

Geoffrey Ziskovin

Geoffrey Ziskovin is an American Software Developer and Author with an experience of over 30 years. He started his career with Haskell and has interviewed over 700 candidates for Fortune 500 companies

Read More

Improved & Reviewed by:

OpenGenus Foundation OpenGenus Foundation
Convert uint8_t* to char* in C++
Share this