From: "vadiraj c s" Subject: Re: Re: code explaination Date: 19 Sep 2003 05:21:39 -0000 Sender: linux-fsdevel-owner@vger.kernel.org Message-ID: <20030919052139.3375.qmail@webmail26.rediffmail.com> Reply-To: "vadiraj c s" Mime-Version: 1.0 Content-Type: text/plain; format=flowed Cc: linux-fsdevel@vger.kernel.org Return-path: Received: from webmail26.rediffmail.com ([203.199.83.148]:4316 "HELO rediffmail.com") by vger.kernel.org with SMTP id S261305AbTISFYp (ORCPT ); Fri, 19 Sep 2003 01:24:45 -0400 To: "Bryan Henderson" Content-Disposition: inline List-Id: linux-fsdevel.vger.kernel.org On Thu, 18 Sep 2003 Bryan Henderson wrote : > >On x86, which is little endian, this will contain > >the value 100 (0x64). On a big endian machine this will be >zero. When you > >access pqr.i = 300, the lowest byte will be 44 (0x2c) on little >endian >and > >zero on big endian. > >That doesn't explain the behavior he asked about: > > >> output: > >> char abc 0 > >> int abc 300; > >> swap the structure value to i=300,j = 100; > >> you get > >> char abc 1; > >(i.e. the values are 0 and 1, not 100 and 44 or 0 and 0). > >Not only that, the "int abc 300" line is inconsistent with the >program >posted, and the program posted won't even compile because there's >a typo >in the name of the abc_int() definition. > >It looks like there's a lot of reason to believe that there is >just an >experimental error here. > > > #include > > struct xyz{ > > > > int i; > > int j; > > } pqr = {100,300} ; > > int main() > > { > > struct xyz *z ; z = &pqr; > > abc_char(z); > > abc_int(z) ; > > } > > > > void abc_char(char *i) > > { > > printf("char abc %d",*i) ; > > } > > > > void abc_int(int *i) > > { > > printf("int abc %d",*i) ; > > } > >- >To unsubscribe from this list: send the line "unsubscribe >linux-fsdevel" in >the body of a message to majordomo@vger.kernel.org >More majordomo info at >http://vger.kernel.org/majordomo-info.html I apologize for the syntax mistake, as you said it does not explain the behavior of the code.... I knew the output to be as he explained, but it din't whats the reason... it was executed on x86 machine on linux platform, where size of int is 4 bytes... //vadiraj ___________________________________________________ Television meets Accounts; Jyoti Weds Rajaram. Rediff Matchmaker strikes another interesting match !! Visit http://matchmaker.rediff.com?1