delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/13/15:45:20

Message-ID: <39468EBA.6E8EB6B3@earthlink.net>
From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Organization: Nocturnal Aviation
X-Mailer: Mozilla 4.73 [en] (Win95; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: conversion specifier.
References: <008501bfd532$7aee9380$de0f3acb AT default>
Lines: 38
Date: Tue, 13 Jun 2000 19:41:30 GMT
NNTP-Posting-Host: 63.23.128.163
X-Complaints-To: abuse AT earthlink DOT net
X-Trace: newsread2.prod.itd.earthlink.net 960925290 63.23.128.163 (Tue, 13 Jun 2000 12:41:30 PDT)
NNTP-Posting-Date: Tue, 13 Jun 2000 12:41:30 PDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com


Alastair Hogge wrote:
> 
> My Code:
> unsigned long foo;
> printf("%d", foo);
> 
> My compiler warnings:
> ..warning: int format, long int arg (arg 2)
> 
> What does this mean? Is it the "%i" thingy?

It means that you are using an int specifier %d in the format string,
while trying to print an unsigned long foo.  

> How can make that warning vanish?

By

1) using the correct specifier

   printf("%lu", foo);

or, not recommended,

2) Taking a chance on loss of information by downcastng foo:

   printf("%d", (int)foo);

 
-- 
Martin Ambuhl	mambuhl AT earthlink DOT net

What one knows is, in youth, of little moment; they know enough who
know how to learn. - Henry Adams

A thick skin is a gift from God. - Konrad Adenauer

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019