Get up to 50 % extra points for free! More info
Save up to 80 % on our JavaScript e-learning courses. Only this week!
discount week 50

Discussion: Issue with ASCII codes

jmillberry:11/11/2016 14:08

I thought I understood ASCII codes from the lesson, but I don't get why casting a string to an int gives its ASCII value...

int i = (int)c;
i += shift;
// overflow control
if (i > (int)'z')
        i -= 26;
char character = (char)i;
message += character;

I know, noob alert, but can someone please tell me why that is?

11/11/2016 14:08
Replies to jmillberry
Luboš 'Satik' Běhounek:11/11/2016 15:56

When you cast char to int, you get the ascii value of the char, because all chars are in memory stored as corresponding number value.

Up Reply
11/11/2016 15:56
Replies to Luboš 'Satik' Běhounek
Prince Vivek Ozovehe:5/24/2017 13:23

If u cast char in to into,u will get ASCII BC all the memory is been stored corresponding number value or digit

Up Reply
5/24/2017 13:23
jamaima cyrus
jamaima cyrus:9/7/2021 4:03

I'm a part-time programmer. Sometimes I even have trouble doing programming. Like in Loops. But I'm skeptical of seniors. After university, I am very busy with my job heftiness, so that's why I cannot do my essay. So, I, buy essay UK and get the greatest grades.

Up Reply
9/7/2021 4:03
Samuel Jackson:12/28/2021 10:17

This is actually the kind of information I have been trying to find. Thank you for sharing this information.

Up Reply
12/28/2021 10:17
To maintain the quality of discussion, we only allow registered members to comment. Sign in. If you're new, Sign up, it's free.

5 messages from 5 displayed.