unsigned char to int in C++

user1346664 picture user1346664 · May 12, 2012 · Viewed 85.4k times · Source

I have a variable unsigned char that contains a value, 40 for example. I want a int variable to get that value. What's the simplest and most efficient way to do that? Thank you very much.

Answer

Oliver Charlesworth picture Oliver Charlesworth · May 12, 2012
unsigned char c = 40;
int i = c;

Presumably there must be more to your question than that...