Thread: size_t

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    144

    size_t

    just wondering what is the point of this function "size_t"

    does the program below do the same thing as size_t?


    Code:
    	int x;
    	x=sizeof(char);
    	printf("%d",x);
    Code:
    size_t x=sizeof(char);
    printf("%d",x)
    ------------------------

    also, what does this syntax mean?

    total=total<4 ? 4U:total;
    Last edited by bos1234; 03-04-2011 at 05:25 AM.

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    size_t is not a function, it's a typedef of an unsigned integer datatype.

    sizeof is a compile-time operator that gives you the size of the datatype passed.

    The ?: construct is called the ternary operator. It's equivalent to

    Code:
    if (total < 4)
    {
        total = 4U;
    }
    else
    {
        total = total;
    }

Popular pages Recent additions subscribe to a feed