HARRIS FLAME Re: SHORT vs. INT
Guy Harris
guy at sun.uucp
Mon Sep 16 16:42:38 AEST 1985
> >People who use the C language should be sufficiently expert that they
> >understand that "long" and "short" should not be selected in favor of "int"
> >only if they are of different sizes on the machine you're coding on.
>
> But I can't quite fiqure out what you mean here. Does it mean that is
> if 'short' 'int' and 'long' are the same size then I should choose
> something other than 'int'?
You did figure out what I meant - that is exactly what I mean! If you want
to have a variable that can hold values outside the range -32767 to 32767,
use "long", regardless of whether something else just might happen to work.
It won't work on other machines, and unless you can guarantee that the code
will *never* be run on another machine, you shouldn't do it.
> Some of us have not been formally trained to program in C.
> Some of us, out of curiosity, desire to use something "better" than
> fortran, or other reason, have taught ourselves C by reading K&R and
> writing programs.
Too many postings here indicate that the poster skipped the "reading K&R"
part or didn't read it very well.
> Some of us are not able to devote all our time to working with
> computers because we have other professions.
Presumably, a physicist building a piece of electronic equipment will have
learned enough about electronics not to put 110V across a microprocessor
chip. Somebody using C (or any other language) for, say, a program in a
physics experiment should have learned enough to know the basics of
portability, and of pointer use, and...
> Some of us do not have access to more than one machine and thus, though
> we'd like to write portably, have know way of experimantally finding out
> what is and is not portable.
You don't find out what's portable by experimenting. You find out by
reading something like Harbison and Steele's "C: A Reference Manual". All
experimenting will do is indicate whether something will work on the
machines you happen to have at hand.
What I'm saying is that some questions - and FAR too many answers - seem to
be posted before the poster has checked any references, or read K&R, or
otherwise done a bit of legwork themselves.
Guy Harris
More information about the Comp.lang.c
mailing list