What is the address of buf (local variable in main function)?
I was doing programming in C classes and I asked the question:
What is the address of buf (local variable in main function)? Enter your answer in hexadecimal (0x followed by 8 "digits" 0-9 or af, such as 0xbfff0014) or decimal. Note that we want the buf address, not its contents.
the code looks like this:
int main(int argc, char *argv[]) {
while(1) {
char buf[1024] = {0};
int r;
....
So I ran gdb
and just put a breakpoint on the line char buf[1024]
and typedgdb
p &buf
and this gives me the result: 0xbffff0f0
but when I use this number in this quiz it gives me the result that this value is not correct.
My question is: is this (p & buf) the address of the buf variable? Or if not, why not?
The exercises are done on a prepared VirtualBox machine, so I think everyone should have the same addresses