Re: Promoting unsigned long int to long int



pereges wrote:
btw, i see a lot of people saying that size_t must be used over
unsigned long. The question is are there any fix guidelines as to when
i should and when i shouldn't use size_t. It seems to me that size_t
is most commonly used in three situations :

1. Size of array or any object.
2. Array indices.
3. Count of something.

Although I don't see why using unsigned long for any of the above
could be wrong. It may not be a necessity to use size_t

size_t is for counting parts of an object.
That's cases 1 and 2 of your list.
In terms of efficiency, you can expect that size_t
will probably be the fastest type that is big enough
to do the job.

When I count nodes in linked list, I use long unsigned.
The number of nodes that malloc can generate,
isn't related to size_t.

--
pete
.



Relevant Pages

  • Re: Promoting unsigned long int to long int
    ... pereges writes: ... The question is are there any fix guidelines as to when ... making it suitable for array indices. ... The third is a bit more iffy; it depends on what you're counting. ...
    (comp.lang.c)
  • Re: Promoting unsigned long int to long int
    ... btw, i see a lot of people saying that size_t must be used over ... The question is are there any fix guidelines as to when ... Array indices. ...
    (comp.lang.c)