see the concept of LITTLE ENDIAN and BIG ENDIAN On Fri, Sep 23, 2011 at 12:23 PM, vishwa <[email protected]> wrote:
> int a=256; > imagine integer is 4 bytes. > so in memory it will look like this > 00000000--last byte.. > 00000000 > 00000001------- p > 00000000---starting byte of a > but the char pointer is pointing to 1 byte of integer, > u incremented it point to 2nd byte > and assigned the new value 2(it was 1 before) > > so it became 512.. > 00000000 > 00000000 > 00000010----p > 00000000 ---- a > > On Thu, Sep 22, 2011 at 6:21 PM, rohit jangid <[email protected]>wrote: > >> isn't that simply because if little indian endian way of storing bytes in >> memory >> >> initial -- 00000000 00000001 0...... >> finally-- 00000000 00000010 0...... >> >> On Sep 22, 2011 5:38 PM, "Rohit Upadhyaya" <[email protected]> >> wrote: >> > >> > int main() >> > { >> > int a=256; >> > char *p=&a; >> > *++p=2; >> > printf("%d",a); >> > return(0); >> > } >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups "Algorithm Geeks" group. >> > To post to this group, send email to [email protected]. >> > To unsubscribe from this group, send email to >> [email protected]. >> > For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- *Anil Arya, Computer Science * *Motilal Nehru National Institute of Technology,Allahabad . * -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
