#include<stiod.h> int main(void) { int i=0xff00ff11; printf("%x\n", i); i = htonl(i); printf("%x\n", i); }
I feel endianness better explained by this code In networking domain , this has importance . This code segment is used when a data is planning to send a big endian machine from a little endian machine Regards RNP On Thu, Jun 7, 2012 at 1:05 PM, atul anand <atul.87fri...@gmail.com> wrote: > @Abhishek : correct .... > > > On Thu, Jun 7, 2012 at 1:03 PM, Abhishek Sharma <abhi120...@gmail.com>wrote: > >> oh ,now i see. 300 = 0000000100101100 >> first 8 bits = 00000001 >> last 8 bits = 00101100 >> >> in case of big-endian machine, when we assign 2 to next location, last 8 >> bits become 00000010 (2 in decimal), first 8 bits remain same. >> in case of little-endian machine, when we assign 2 to next location, last >> 8 bits become 00000010 (2 in decimal), last 8 bits remain same. >> >> Am i right ? >> >> On Thu, Jun 7, 2012 at 12:53 PM, Abhishek Sharma <abhi120...@gmail.com>wrote: >> >>> @prem, i don't get it.could you please elaborate the interesting part of >>> this solution ? >>> >>> >>> On Thu, Jun 7, 2012 at 11:39 AM, Abhishek Sharma >>> <abhi120...@gmail.com>wrote: >>> >>>> Is there any online compiler which gives output for both little/big >>>> endian machines ? >>>> or it is fine to convert value from one form to another using a small c >>>> program ? >>>> >>>> On Thu, Jun 7, 2012 at 1:13 AM, Garima Mishra <garima9...@gmail.com>wrote: >>>> >>>>> 556 if the machine is little endian >>>>> 258 if machine is big endian >>>>> >>>>> On Jun 6, 11:57 pm, g4ur4v <gauravyadav1...@gmail.com> wrote: >>>>> > main() >>>>> > { >>>>> > int i=300; >>>>> > char *ptr = &i; >>>>> > *++ptr=2; >>>>> > printf("%d",i); >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > } >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Algorithm Geeks" group. >>>>> To post to this group, send email to algogeeks@googlegroups.com. >>>>> To unsubscribe from this group, send email to >>>>> algogeeks+unsubscr...@googlegroups.com. >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>> >>>>> >>>> >>>> >>>> -- >>>> Abhishek Sharma >>>> Under-Graduate Student, >>>> PEC University of Technology >>>> >>>> >>> >>> >>> -- >>> Abhishek Sharma >>> Under-Graduate Student, >>> PEC University of Technology >>> >>> >> >> >> -- >> Abhishek Sharma >> Under-Graduate Student, >> PEC University of Technology >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> 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 algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.