[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] C help plz..



But isn't %[Xx] just prints out as Hexdecimal?
I just tried, and it prints out something like: 38c9616e

which consumes 8 bytes in a file. Given that unsigned long is 32 bits,
I want to use exactly 4 byte to represent it in order to save some
space.

Thanks.

Shao.

Matthew Dalton [matthewd@research.canon.com.au] wrote:
> Try using %X or %x instead of %ld
> 
> Shao Zhang wrote:
> > 
> > Hi,
> >         If I have an unsigned long int, instead printing out its values
> >         in string using printf("%ld\n", my_var),
> > 
> >         I would like to print it out as a 4-byte binary data. Is there
> >         any easy way to do this in C.
> > 
> >         Thanks.
> > Shao.
> > 
> > --
> > ____________________________________________________________________________
> > Shao Zhang - Running Debian 2.1  ___ _               _____
> > Department of Communications    / __| |_  __ _ ___  |_  / |_  __ _ _ _  __ _
> > University of New South Wales   \__ \ ' \/ _` / _ \  / /| ' \/ _` | ' \/ _` |
> > Sydney, Australia               |___/_||_\__,_\___/ /___|_||_\__,_|_||_\__, |
> > Email: shao@cia.com.au                                                  |___/
> > _____________________________________________________________________________
> > 
> > --
> > Unsubscribe?  mail -s unsubscribe debian-user-request@lists.debian.org < /dev/null
> 

-- 
____________________________________________________________________________
Shao Zhang - Running Debian 2.1  ___ _               _____
Department of Communications    / __| |_  __ _ ___  |_  / |_  __ _ _ _  __ _ 
University of New South Wales   \__ \ ' \/ _` / _ \  / /| ' \/ _` | ' \/ _` |
Sydney, Australia               |___/_||_\__,_\___/ /___|_||_\__,_|_||_\__, |
Email: shao@cia.com.au                                                  |___/ 
_____________________________________________________________________________


Reply to: