Code: Select all
struct foo_t *act;
act+= sizeof(struct foo_t);
I also tried:
Code: Select all
struct __attribute__((__packed__)) foo_t
{
int a,b,c;
};
Code: Select all
struct foo_t *act;
act+= sizeof(struct foo_t);
Code: Select all
struct __attribute__((__packed__)) foo_t
{
int a,b,c;
};
Code: Select all
struct foo_t *act;
act+= sizeof(struct foo_t);
Code: Select all
struct foo_t *act;
act+= 1;
In C99, you have the type intptr_t (located in <stdint.h>) for this, so you don't have to worry about whether a pointer fits into int or long or long long...bluecode wrote: You have to cast the pointer to unsigned int/unsigned long add the value and cast it back to the pointer type.
Well... if you want to actually do plain math with pointers, you'll have to cast it either to a char * or to an intptr_t (at your preference) and then do the math.FlashBurn wrote: Ok, thanks I?m not used to C programming, normaly I write my code in asm.
So how is the right code when I want to use the value of a pointer (the address) and want to add some other value?