User Tools

Site Tools


c:stdlib.h:sizeof

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:stdlib.h:sizeof [2024/02/16 01:04] (current)
Line 1: Line 1:
 +{{keywords>wiki library source code example reference}}
 +===== sizeof =====
 +<code c>
 +#include <stdlib.h>
 +
 +    int sizeof(VALUE);
 +</code>    
 +    sizeof operator returns the number of bytes to be reserved for a variable or a data type.
 +
 +===== C Sourcecode Example =====    
 +<code c>
 +#include <stdio.h> /* including standard library */
 +#include <stdlib.h>
 +//#include <windows.h> /* uncomment this for Windows */
 +
 +
 +int main(void){
 +
 +printf("int:         %d bytes\n", sizeof(int) );
 +printf("Hello World: %d bytes\n", sizeof("Hello World") );
 +
 +return 0;
 +}
 +
 +</code>
 +
 +==== Output ====
 +
 +    Output:
 +    user@host:~$ ./sizeof 
 +    int:         4 bytes
 +    Hello World: 12 bytes
 +
  

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/stdlib.h/sizeof.txt · Last modified: 2024/02/16 01:04 (external edit)

Impressum Datenschutz