HELLO

HI GUYS.
Main reason I am posting is to say hello as i just joined:)

Thank you admin for making the tutorial, it helped me a lot :)


I am new here and am confused :p

It says beginner but what are you calling beginner?

Anyway my question :p

The code below: what does it do??

char convertToColor(int num)
{
switch (num)
{
case 1:
return static_cast<char>(66);
case 2:
return static_cast<char>(71);
case 3:
return static_cast<char>(79);
case 4:
return static_cast<char>(80);
case 5:
return static_cast<char>(82);
case 6:
return static_cast<char>(89);
}
} // end convertToColor
Please put code in
[code]
and
[/code]
tags. It makes it easier to read
What that code does is a function that takes the parameter of int num and spits back a character. The values of the switch-case statements are valued 1 -6 which spit back, to me a randome character, that are in the upper aphla set but I would have to look at the ascii set to verify.
Since there is no default case (or a return statement after the switch), this function produces undefined behaviour if num is not in the range [1, 6].
thANKS
Topic archived. No new replies allowed.