Arduino parsing a uint8_t variable using strtok()

Hello,

I’m finding it hard to understand the different data types in Arduino.

I am using a library for a radio shield that receives data in the form of uint8_t variable which I understand is essentially the same as a unsigned char and a byte in Arduino.

I want to parse the incoming variable by the colon using strtok(). However, the first argument of strtok is required to be a char*.

Is there a way to convert the uint8_t variable to a char? or is there another function more suitable to parsing variables of type uint8_t? I cannot change the variable on the transmitter.

An example of the uint8_t variable is “temp:2.4,number:300,humidity:54.567”

I searched google but have been unable to find a solution.

Thank you for your assistnace

I am using a library for a radio shield that receives data in the form of uint8_t variable

Very unlikely. A uint8_t ARRAY would make more sense.

A uint8_t and a char are the same size. So, it you have a function that expects a char array, and you have a uint8_t array, lie to the function, by using a cast.

uint8_t crosspostedCrap[] = "temp:2.4,number:300,humidity:54.567";
char *token = strtok((char *)crosspostedCrap, ":");

And stop posting new threads about the same damned problem.

@johngalileo, did you post the same question two hours apart multiple times using different accounts?

johngalileo:
I want to parse the incoming variable by the colon using strtok(). However, the first argument of strtok is required to be a char*.

How to use this forum

Your code? Your error message?

Please use code tags.

Read this before posting a programming question