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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] > > |___/ > > _____________________________________________________________________________ > > > > -- > > Unsubscribe? mail -s unsubscribe [EMAIL PROTECTED] < /dev/null > -- ____________________________________________________________________________ Shao Zhang - Running Debian 2.1 ___ _ _____ Department of Communications / __| |_ __ _ ___ |_ / |_ __ _ _ _ __ _ University of New South Wales \__ \ ' \/ _` / _ \ / /| ' \/ _` | ' \/ _` | Sydney, Australia |___/_||_\__,_\___/ /___|_||_\__,_|_||_\__, | Email: [EMAIL PROTECTED] |___/ _____________________________________________________________________________