Re: why use fprintf / size_t instead of printf/ int

From: Vesa Siivola (vsiivola_at_cc.hut.fi)
Date: 02/14/05


Date: Mon, 14 Feb 2005 10:05:58 +0200 (EET)

Keith Thompson <kst-u@mib.org> wrote:
: Use size_t for what? You didn't quote anything from the previous
: article, and I can't find it on my news server (and you didn't even
: post through google).

I could not find the original question either, just some flaming
follow-ups. I guess it was a bit pointless to even reply to such an
old message anyways. Good thing you guessed the original question
right.

: The base address is of a pointer type, not of type size_t. It's
: likely to be the the same size as a size_t, but whether any conversion
: is required, and how much (if anything) it costs, is system-specific.

You are right. Again, just guessing, its probably less likely that a
size_t should be converted than int. But this is just nitpicking.

: There may be good reasons to use size_t rather than int as an array
: index, but this kind of micro-optimization isn't one of them.
I agree.

Vesa



Relevant Pages

  • Re: Lets write a c program, without knowing what it does...
    ... >>int LowerLimit ... conversion from any one pointer type to any other, ... > Possible undefined behaviour here. ...
    (comp.lang.c)
  • Re: Pointer
    ... cannot be converted to a pointer type. ... incompatible pointer types; a pointer to int and a pointer to float may ... the %u conversion specifier expects an unsigned int as ...
    (comp.lang.c)
  • Re: not declaring something to equal null
    ... It is undefined if the result of the conversion cannot ... be represented in an int but implementation-defined otherwise. ... "Any pointer type may be converted to an integer type. ...
    (comp.lang.c)
  • Re: Problem with linker
    ... but to have actually written a default constructor. ... such as overloading on int and pointer types. ... conversion of 0 to CString requires a user-defined conversion, ... acceleration operator *(distance d, time_squared t2); ...
    (microsoft.public.vc.mfc)
  • Install Curses for Bastille Install
    ... This is on a brand new install of fedora core 1. ... function 'nocbreak' returns int ... CursesFun.c:1279: warning: initialization from incompatible pointer type ...
    (perl.beginners)