4

I need convert unsigned char array into unit8_t array maybe someone has an idea how to do it?

I tried to look for information on the Internet, but unfortunately I did not succeed.

:)

1
  • There's nothing to convert. Iff uint8_t exists, it is the same as unsigned char. Or the other way around: If unsigned char has more than 8 bits, there's no uint8_t available. Commented Jul 28, 2017 at 11:01

2 Answers 2

6

So, have you tried uint8_t* myuint8array = (uint8_t*)myuchararray; ?

Sign up to request clarification or add additional context in comments.

Comments

1

You have

unsigned char arr[size];

and you want

uint8_t arr[size];

uint8_t is simply defined as

typedef unsigned char uint8_t;

:-)

9 Comments

Or not defined at all, in case char has more than 8 bits.
And when would a character possibly have more than 8 bits?
@Robert - It could for example be 9 bits on a 36-bit computer.
character != char. And then, the answer is "when it has more than 8 bits". Yes, such platforms exist and they can't provide uint8_t for obvious reasons.
This was complete news to me, i have never heard of this before. Thanks, will read this straight away. :-)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.