In C/C++ sizeof() operator is used to find size of a date type or variable. Expressions written in sizeof() are never executed.
Examples:
#include <stdio.h>
int main(){
int a = sizeof ( printf ( "hey" ));
printf ( "%d" , a);
return 0;
}
|
Output:
4
Even if we assign a value inside sizeof(), the changes are not reflected.
#include <stdio.h>
int main() {
int a = 5;
int b = sizeof (a = 6);
printf ( "a = %d, b = %d\n" , a, b);
return 0;
}
|
Output:
a = 5, b = 4
If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
02 Oct, 2017
Like Article
Save Article