0
unsigned int someInt = 'MPG3';

someInt will now hold a value of 1297106739. I always thought the compiler would complain if more than 1 character was within single quotes. I would like to know how the compiler is getting this value, and if it's possible to retrieve the char value.

char someChar = someInt;
char someChar = (char)someInt;

They don't work.

cool mr croc
  • 725
  • 1
  • 13
  • 33
  • 1
    About the second part of the question: Are you aware that a single char variable can´t hold 4 chars (or anything as big as 4 chars)? – deviantfan May 23 '15 at 16:31
  • good point. Is there a quicker way to read it into a char array than bitshifting for each individual character? – cool mr croc May 23 '15 at 16:37
  • `(char *)(&someInt)` (but there is no \0, and remember that while it´s allowed everywhere, the value of someInt itself is implementation-defined) – deviantfan May 23 '15 at 16:39

0 Answers0