Saturday, December 29, 2018

Forcing word alignment of string pointers

typedef union {
unsigned long l;
char * s;
void * lp;
} Val;

int main() {

struct {
char ch;Val v; } st;
printf("%x %x \n",&st.ch,&st.v);

}

Seems to work. Thus we should be able to assign packed chars directly onto a word.

No comments: