0

SOLVE MISERABLY How the output is 97 ? Pointer

howwwww.. just some exercise from internet for me..still struggling.. https://code.sololearn.com/cmyBNYO8is5y/?ref=app

1st Sep 2018, 11:43 PM
Muhamad Fathi Zuhaili
Muhamad Fathi Zuhaili - avatar
6 Respostas
+ 5
The output is 1A.
2nd Sep 2018, 12:24 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 3
Anyways it's by ASCII value. Character addition refers to their ASCII value.
2nd Sep 2018, 12:25 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
output is not 97 and it's 1A??😊
2nd Sep 2018, 1:47 AM
Rishabh
Rishabh - avatar
+ 2
What's line 9 supposed to do? You're adding the char the pointer is pointing to to the pointer. That doesn't change the output, but ptr2 is now pointing to some random memory location that may or may not contain data. If you want to change the value of the char, use *ptr2 += char1 instead. P. S. Here's a way to change the output to 97, if that's what you want to do (including a useless pointer): char char1 = 'a'; char *ptr1 = &char1; cout << (int)*ptr1;
2nd Sep 2018, 6:05 AM
Anna
Anna - avatar
+ 2
97 is the int value of the ASCII char 'a'.
2nd Sep 2018, 3:17 PM
Anna
Anna - avatar
+ 1
Anna oh so you're saying that 97 is just generated number.. and not algorithm.. in code block I got 97 somehow
2nd Sep 2018, 3:11 PM
Muhamad Fathi Zuhaili
Muhamad Fathi Zuhaili - avatar