I'm somewhat new to pointers, when I ran this program, I got an output where I'm confused. How do you get those long addresses for some of those? How would you know this if I didn't run this on compiler?
How do you get those long addresses for some of those?
Those long numbers represent the memory locations that the values have been placed into.
How would you know this if I didn't run this on compiler?
There is no way to know what they are going to be just by looking at the source code; their value depends on where in the actual memory those values get placed, which is a combination effect of the compiler and the operating system.
0x just means the number being shown to you is in hexadecimal format. It's just a number. 0x7cd64ee28960 is the decimal number 137259888314720.
If an exam showed you this code, and asked you what memory address variables would be in, and you hadn't already been told a whole lot of detail about how the compiler etc. likes to organise its memory, you would write "Are you serious? Am I paying you actual money for this education? You don't know what you're talking about and I'm very angry about it."
Edit: I have been double ninja'd :+) Have to learn to type faster :+D
How do you get those long addresses for some of those?
You don't. They are just whatever the address of that variable happens to be. The address is originally 64 bit (or 32 bit) 0's and 1's, it's displayed in hex format with the leading 0x.
What that number actually is, is irrelevant: The address of variable X is what it is, we don't care what it's actual number is. This is true even when we do pointer arithmetic. If one was to add 1 to the variable which holds the address of the first element in an array, the compiler uses the size of the type of the array to calculate the address of the next element in the array.
How would you know this if I didn't run this on compiler?
The addresses will vary, quite possibly every time you run it on the same machine, and definitely with different machines / compilers. But as I say, it's irrelevant.