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
Release: 2023-09-08 12:25:05
forward
1241 people have browsed it

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);
}
Copy after login

Output

The size: 4
The size: 8
Copy after login

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!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template