On Fri, 10 Apr 2009, Namita wrote:

> >  From: Saifi Khan <[email protected]>
> >  Subject: [twincling] two C programs
> >  Sent: 10 Apr '09 04:21
> >  
> >  Hi all:
> >  
> >  What is the difference between the following two C programs ?
> >  
> << snipped >>
> >  All observations and insights are very welcome.
> >  
> >  
> >  thanks
> >  Saifi.
> >  
> 
> Ran both snippets on little endian and big endian machines.
> In all (four) cases the results were the same.
> 
> Did you observe something different ?
> 
> 
> Details:
> 
> (gdb) b main
> Breakpoint 1 at 0x8048350: file hex-char.c, line 5.
> (gdb) r
> Starting program: ~niyer/trials/hex-char
> 
> Breakpoint 1, main (argc=1, argv=0xbfe72a34) at hex-char.c:5
> 5           unsigned char uc[] = "\xFF";
> (gdb) n
> 6           return 0;
> (gdb) p uc
> $1 = "ÿ"
> (gdb) p /x uc
> $2 = {0xff, 0x0}
> 
> 
> ---
> 
> 
> (gdb) b main
> Breakpoint 1 at 0x8048350: file hex-char.c, line 16.
> (gdb) r
> Starting program: ~niyer/trials/hex-char
> 
> Breakpoint 1, main (argc=1, argv=0xbff2ccd4) at hex-char.c:16
> 16          unsigned char uc[2] = { (unsigned char)(char) 0xFF, 0 };
> (gdb) n
> 18          return 0;
> (gdb) p uc
> $1 = "ÿ"
> (gdb) p /x uc
> $2 = {0xff, 0x0}
> (gdb)
> 

Namita, you're right. 

There is *no* difference between the two programs :)


thanks
Saifi.

[Non-text portions of this message have been removed]



------------------------------------

Twincling Technology Foundation 
freedom of innovation
http://twincling.org/
http://twitter.com/twincling
----------------------------------------
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/twincling/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/twincling/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to