sizeof() and size_t

Home Forums C-programming.. sizeof() and size_t

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2179 Reply
    Humble
    Keymaster

    Almost everyone know about sizeof operator in C and its use .mostly you have used or noticed passing arguments in functions like mallo() or memcpy().. In simple terms, it provides the size of an object and its syntax looks like “sizeof(object)” ..

    sizeof() provides its return in “size_t” form.

    In gnu C library environments, this is an unsigned int or unsigned long int data type.. So when using format specifier inside printf to print the size of an object, try to cast to (unsigned long) ..

    For ex:

    printf("%lu", (unsigned long)sizeof(thetype));
    
    
       
    #2180 Reply
    Humble
    Keymaster
    This reply has been marked as private.
Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: sizeof() and size_t
Your information: