well, thank you very much about your article on expert-exchange.com ,, well, what i am asking about , is how can i put four chars in a ulong,, i do know that ulong=4bytes, and char = 1 byte, i do like that:
ulong value1 ;
char ss[]="name";
value =ss ;
that is the problem ,, i don't want to put the first char in the ulong,, i do want to put the whole string in it,,, i will be thankful if you reply me ,
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;