Cannot convert 'String' to 'uint8_t {aka unsigned char}' in initialization

Hey all I am trying to convert a string into a uint8_t with the following code:

String data = "#255101987";
String tmp1 = data.substring(1, 3);

uint8_t first  = (String)tmp1.substring(1, 3);

I am getting the error of:

cannot convert 'String' to 'uint8_t {aka unsigned char}' in initialization Any help would be great as I thought adding (String) in front of the varible would solve the issue but it hasn't as you can tell.

Cross posted on http://arduino.stackexchange.com/questions/12979/cannot-convert-string-to-uint8-t-aka-unsigned-char-in-initialization

How do you expect to fit more than one char into a char variable ?

Answer provided by nick:

uint8_t first  = atoi (tmp1.substring(1, 3).c_str ());   
Or even:

String data = "#255101987";
uint8_t first  = atoi (data.substring(1, 3).c_str ());

And FYI Nick, that would not be a cross post.. A cross post is when its on the same site...

Google "Cross-post".

post (a message, link, image, etc.) to more than one online location, such as a blog, social media website, or forum.

More than one online location is pretty clear.

Also:

http://dictionary.reference.com/browse/cross-post

to post (the same message) to two or more message boards or electronic mailing lists at the same time.

That's exactly what you did. So in my case, I am now answering the question twice, and you are doubling the work people have to do. Some answer on one site, some on another.

My suggestion is, at least wait a day or two after posting on site A before posting on site B. And maybe mention: "I asked this two days ago on StackExchange, but no-one could help me."

More than one online location is pretty clear.

Weird. :roll_eyes: