A "clean" way of doing this?
Posted: Tue Oct 16, 2007 10:36 pm
Ok, I have ran into a bit of a problem...
ok, I have a huge array
char big[1024];
ok, so now, I want to write an int to element 5
well, there could be (int)big[5]=my_int;
but that would actually write to big[5*sizeof(int)]
so, exactly how do you go about doing this easily and without temporary variables?
like, basically, a "clean" way to do this:
ok, I have a huge array
char big[1024];
ok, so now, I want to write an int to element 5
well, there could be (int)big[5]=my_int;
but that would actually write to big[5*sizeof(int)]
so, exactly how do you go about doing this easily and without temporary variables?
like, basically, a "clean" way to do this:
Code: Select all
char bah[256];
int *bahi=(void*)&bah[5];
*bahi=0x220;