
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
Anything written in sizeof() is never executed in C
The sizeof function (Sometimes called operator) is used to calculate the size of the given argument. If some other functions are given as argument, then that will not be executed in the sizeof.
In the following example we will put one printf() statement inside the 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
", x); x = sizeof(my_function()); printf("The size: %d", x); }
Output
The size: 4 The size: 8
The printf() is not executed which is present inside the sizeof(). Only the return type is considered, and its size is taken.
- Related Articles
- What is sizeof operator in C++?
- Sizeof operator in C
- Why is sizeof() implemented as an operator in C++?
- What is the use of sizeof Operator in C#?
- Why is not sizeof for a struct equal to the sum of sizeof of each member in C/C++?
- Is there anything like substr_replace in MySQL?
- How will implement Your Own sizeof in C
- sizeof() function in PHP
- Find size of array in C/C++ without using sizeof
- Is finally block always get executed in Java?
- Why isn't sizeof for a struct equal to the sum of sizeof of each member in C/C++?
- Difference between strlen() and sizeof() for string in C
- Result of sizeof operator using C++
- Written version of Logical operators in C++
- Functions that are executed before and after main() in C

Advertisements