Hussain K.

asked • 02/22/20

Why the last value appear in hexadecimal rather than decimal? c++

struct Node

{

Node* next;

int num;

};


int main()

{

Node* ptr = new Node;


ptr->num = 11;

ptr->next = NULL;



cout << ptr << "\n";

cout << &ptr->next << "\n";

cout << "---------------------\n";


cout << &ptr->num << "\n";

cout << &ptr->next + 1 << "\n";

cout << "---------------------\n";


cout << *(&ptr->num) << "\n";

cout << *(&ptr->next + 1) << "\n";

}


00B1E358

00B1E358

---------------------

00B1E35C

00B1E35C

---------------------

11

0000000B



2 Answers By Expert Tutors

By:

Patrick B. answered • 02/23/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Hussain K.

i don't know if the priority is the case here cout << *(&ptr->num) << "\n"; cout << *(&ptr->next + 1) << "\n"; because the last two lines are almost same num = next + 1 but when print it first value appear decimal and the second hexadecimal
Report

02/23/20

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.