X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: Mok-Kong Shen Newsgroups: comp.os.msdos.djgpp Subject: A printf problem? Date: Sat, 10 Sep 2011 15:37:09 +0200 Organization: albasani.net Lines: 30 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net V4y8yzTVJ9iEqzIyl4kxDc9CafxCsNPPPGCQyjlGTyJgDDXGsoHQIVYL9U3wKkjqggYdlL+VbfYvTr/j4AzZ6A== NNTP-Posting-Date: Sat, 10 Sep 2011 13:35:10 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="6+5iLi1Cn0if9AjjBwILCa9ril5Z2Vstd00iIeEXWuTpMKIvqL66cv8iXTRMNSEmbnqK+ChhoNzdsvy5lDgYdkx33TSBLCaKeSTcyOJVEJAs6TJhPzVIbSDrrYVG7GCm"; mail-complaints-to="abuse AT albasani DOT net" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 Cancel-Lock: sha1:JCKX/Qqy9R9AFNPcNDncWXpurnw= Bytes: 1795 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi, Maybe I have made a very grave mistake, but I just can't yet understand why the code attached below produced the following output: first: cc22 55258 second: d7da 55258 third: ffff 65535 Why are the first two numbers, which are different hexadecimals, printed out as the same decimal number? Thanks for your kind help in advance. M. K. Shen ------------------------------------------------------ #include int main() { unsigned long int g; g=0xcc22; printf("first: %8x %10lu\n",g,g); g=0xd7da; printf("second: %8x %10lu\n",g,g); g=0xffff; printf("third: %8x %10lu\n",g,g); return(0); }