NOTE : I have used the test string as "nam" and NOT
"name" bcoz char is one byte agreed and ULONG is 4
bytes , agreed. But what about the NULL termination
character. If u use the string "name", its actually
4 characters PLUS one character for NULL. That makes
it 5 CHARACTERS. That cant be possibly put into a
ULONG. It will only lead in buffer overflows and
unpredictable results.
what about this code?
union a
{
struct b{
char c ;
};
ulong d;
};
union a x;
x.b.c ='n';
x.b.c = 'a';
x.b.c ='m';
x.b.c ='e';
char name[]="name"
for(int i=0; i < strlen(name);i++)
x.b.c = name ;
ulong u = x.d;