How to Convert the char* to unsigned char*

I need conver an array from char type to unsigned char type, Who can tell me how to make this convert , is there has a function? I have not find it in the language reference

thank u

I need conver an array from char type to unsigned char type

Why? Both types are exactly the same size. At most, you might need to lie to a function, and tell it that one type can be trusted to be another type. That is done with a cast.

Exactly how depends on your code. Which we can't see.

I want show the temperature from DS18B20 in LCD12864, there has a library to use the LCD, but it use unsigned char type array, and the date from DS18b20 is float type, so I use dtostrf() function to make this convert, but dtostrf can only conver the float to char but not unsigned char, I need go on convert from char to unsigned char

this is my code

/*
LCD Arduino
PIN1 = GND
PIN2 = 5V
RS(CS) = 8;
RW(SID)= 9;
EN(CLK) = 3;
PIN15 PSB = GND;
*/
#include <OneWire.h>
#include <DallasTemperature.h>
#include <stdlib.h>
#define ONE_WIRE_BUS 2
#include “LCD12864RSPI.h”
#define AR_SIZE( a ) sizeof( a ) / sizeof( a[0] )

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

char str[20];
unsigned char str2[20];
double temp =0;
unsigned char show0={
0xD2,0xBA,0xBE,0xA7,0xCF,0xD4,0xCA,0xBE};//液晶显示
unsigned char show1=“LCD1284 Display”;

void setup()
{
Serial.begin(9600);
sensors.begin(); //传感器初始化

LCDA.Initialise(); // 屏幕初始化
delay(100);
}

void loop()
{
sensors.requestTemperatures(); //get the temperature
dtostrf(sensors.getTempCByIndex(0),5,2,str);
str2=unsigned char*(str);
LCDA.CLEAR();
delay(100);
LCDA.DisplayString(0,2,show0,AR_SIZE(show0));
delay(100);
LCDA.DisplayString(1,0,show1,AR_SIZE(show1));
delay(100);
LCDA.DisplayString(2,0,str,AR_SIZE(str));
}

Exactly how depends on your code. Which we can’t see.

yes, I have posted my code

this is the library of LCD Display

LCD12864RSPI.h (740 Bytes)

LCD12864RSPI.cpp (4.84 KB)

You have a char array:

char str[20];

You populate it:

  dtostrf(sensors.getTempCByIndex(0),5,2,str);

Now, you want to show it:

  LCDA.DisplayString(2,0,str,AR_SIZE(str));

But the DisplayString() method expects a unsigned char array. So, lie to it. Tell it that your array is to be treated as a unsigned char array:

  LCDA.DisplayString(2,0,(unsigned char *)str,AR_SIZE(str));

yes, it working. Thanks a lot