questions about size_t



Hello,
I have some questions about the size_t type.
First, what do we know about size_t? From what I have
read I believe that it is an unsigned integer,
but not necessarily an int. Am I correct?

Does this mean that if I need to compare two variables,
one of the size_t type, should the other also be a size_t
variable? There could be problems if I compare it with an
int, if those have different sizes, right?

Most of the time when I make for loops, I use an int variable
as index, like for (int i = 0; ...)
Should I change that to size_t if I need to compare the i
variable with the return value of strlen(), for example?

I think that just adds more things to think about,
wouldn't it be easier to just use an unsigned int, instead
of the size_t variable for strlen, sizeof, etc. ?

Whats the benefit of size_t?
Is there advantage using it for your own stuff, like
struct {
size_t size;
void *stuff;
};
or
make_balloon(size_t balloonsize);

or should it only be used for the standard functions?
.



Relevant Pages

  • Re: fastest sorted list type?
    ... I'm not aware of any scenario you've mentioned in which what you're sorting is "just an int". ... Yes, you have a scenario in which you are sorting a list of ints, but when you actually compare two entries in that list you aren't comparing the integers themselves, but rather the data in an object to which the int refers. ... I did have a look on google and wiki lists al the sort algorothms nicely, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: calling qsort
    ... int mycmp(const void *a, const void *b) ... the compare function. ...
    (comp.lang.c)
  • Re: Is the following code OK?
    ... I have to compare an address of structure with an absolute address. ... int main ... First, as you suspect, it is not possible to compare a pointer ... integer to a pointer by writing (struct t*)0x120000, ...
    (comp.lang.c)
  • Re: Rolling Up Characters = Skewing the Game?
    ... I want a basis to compare die rolls systems ... I need point values for ability scores ... point values below 3 and above 18 to compare them. ... is still some detriment to having a 3 int fighter as opposed to an 8 ...
    (rec.games.frp.dnd)
  • Re: how to compare two time
    ... WC> int begin = time; ... WC> How about COBOL? ... When you want to compare times, it is better to use these functions ... FUNCTION INTEGER-OF-DATE which for many applications is more important ...
    (comp.lang.cobol)