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
6 Respostas
+ 5
The output is 1A.
+ 3
Anyways it's by ASCII value. Character addition refers to their ASCII value.
+ 2
output is not 97 and it's 1A??😊
+ 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;
+ 2
97 is the int value of the ASCII char 'a'.
+ 1
Anna oh so you're saying that 97 is just generated number.. and not algorithm.. in code block I got 97 somehow