> -----Original Message----- > From: civics@oocities.com [mailto:civics@oocities.com] > Sent: Thursday, February 01, 2007 12:46 PM > To: vijay.zanvar@wipro.com > Subject: Survey Results > > Name = manisha > URL = cdac_manisha@yahoo.com > Comments = the structure is defined as below > struct { > unsigned long low; > unsigned long high; > }u_int64; > > the var is declared as > unsigned long long var; > > this variable is manipulated at one place.. basically > assigning some value.. i need to set this value to above structure. > how can i achieve this? > > thanks in advance > manisha > > > subject = Survey Results > REMOTE_HOST: 198.62.10.11 > Hello, Manisha! The following is one method that strikes my mind. Note, however, that I haven't tested it. Please test and kindly notify the result to me. The problem was the way struct was declared. Here is the working program, with little modifications: #include <stdio.h> #include <limits.h> int main () { struct u_int64 { unsigned long low; unsigned long high; }; unsigned long long var; struct u_int64 s64; size_t ulsize = sizeof (unsigned long); size_t ullsize = sizeof (unsigned long long); unsigned int ulshift = ulsize * CHAR_BIT; var = 0x1111111122222222ULL; s64.low = var & (unsigned long) -1; s64.high = (var >> ulshift) & (unsigned long) -1; printf ("ullsize: %d, ulsize: %d, ulshift: %d\n", ullsize, ulsize, ulshift); printf ("var: %#llx, s64.low: %#lx, s64.high: %#lx", var, s64.low, s64.high); return 0; } ullsize: 8, ulsize: 4, ulshift: 32 var: 0x1111111122222222, s64.low: 0x22222222, s64.high: 0x11111111 Best, Vijay Zanvar