Home >Backend Development >C++ >In C language, anything written in sizeof() will not be executed

In C language, anything written in sizeof() will not be executed

WBOY
WBOYforward
2023-09-08 12:25:051245browse

In C language, anything written in sizeof() will not be executed

The sizeof function (sometimes called an operator) is used to calculate the size of a given argument. If some other function is given as argument, then the function will not be executed in sizeof.

In the following example, we will place a printf() statement inside a loop. Then we will see the output.

Example

#include<stdio.h>
double my_function() {
   printf("This is a test function");
   return 123456789;
}
main() {
   int x;
   x = sizeof(printf("Hello World"));
   printf("The size: %d</p><p>", x);
   x = sizeof(my_function());
   printf("The size: %d", x);
}

Output

The size: 4
The size: 8

In sizeof(), printf() will not be executed, only the return type will be considered and its size will be taken.

The above is the detailed content of In C language, anything written in sizeof() will not be executed. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete