Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move pointer one byte

I want to move a pointer forward one byte. But I get this error:

lvalue required as increment operand

With this code:

int **test = 0;
((char *) *test)++;

But it is fine with this:

int **test = 0;
char **t2 = (char **) test;
(*t2)++;

How do I do the latter concisely?

like image 459
donkon Avatar asked Dec 27 '25 20:12

donkon


1 Answers

If you want to increment the value pointed to by a double pointer:

(* (char **) test)++;

which means de-refrence the double pointer named "test" and then increment the value it is currently pointing to.

That will increment the value the pointer is pointing too, not advance the pointer itself. That's what I think you are trying to do in your sample code.

like image 52
Rami Avatar answered Dec 30 '25 09:12

Rami



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!