Sorry, I don't understand your question. *%.2x *is only a precision
specifier still.
(%.2x was used for neat formatting only, because you are printing the
values only 1 Byte long and a Byte can occupy at max 2digits in hex)

>>>>hex representated by 4 bits.
Yes hex is represented by 4 bits i.e. 1 Byte and that's what you are
reading with a char pointer*,  1 Byte each time and printing the values in
those Bytes.

>>>>total we have to represent 32 bits and 8 bits in each....plz xplain
Each output represents 32bits only. 1 Byte each (in total 4Bytes)

It's showing you the memory layout. You stored *i = 1; *and when probed it
using a char pointer. you found following four bytes written:  *01 00 00 00*
It shows that on your machine:
1. int is 4bytes long. (4x1Byte)
2. First byte stores the least significant value, hence you are working on
a Little endian machine.

similarly, for pointer:
char pointer reads 1 Byte at a time. It read 4Bytes in total i.e. 32 bits.
Hence, you are working on a 32 bit machine. (as pointer has value: *44 ff
28 00, *address of i)*.*
*
*
*
*
PS: This is an algorithm group, please refrain from asking such language
specific questions.

On 21 October 2012 00:19, rahul sharma <rahul23111...@gmail.com> wrote:

> Actually i have taken form   http://www.geeksforgeeks.org/archives/730
> Please explain me o/p...as hex representated by 4 bits....then how cum is
> following o/p
>  00 00 80 3f
>  01 00 00 00
>  44 ff 28 00
>  01 00 00 00
>
> total we have to represent 32 bits and 8 bits in each....plz xplain
>
> On Sun, Oct 21, 2012 at 12:05 AM, rahul sharma <rahul23111...@gmail.com>wrote:
>
>> void show_bytes(byte_pointer start, int len)
>> {
>>      int i;
>>      for (i = 0; i < len; i++)
>>            printf(" %.2x", start[i]);
>>      printf("\n");
>> }
>>
>>
>>
>> byte_pointr is unsigned char *...typedef unsigned char * byte_pointer....
>> plz tell me use of %.2x  i knowx is for hexa........does it mean print 8
>> bites of address in 4 hexa of 2 bits???i cant get xactly plz explain
>>
>
>  --
> 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.

Reply via email to