简体   繁体   中英

In GDB, what does *(x+value) = value do?

I understand that

* = dereference

*x = dereferencing x to grab the value in x if x is a pointer.

*x = 5 , set x = 5 if x is a pointer and a variable x exists.

What does the +value portion do here?

Ie. 

x = 5 

*ptr;

ptr = &x

*ptr gives us 5.

x + 5 adds 5*sizeof(*x) to the value of x and dereferences that location.

*(x + 5) is exactly equivalent to x[5] .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM