sizeof Compile Time Operator in C Programming Language Video Tutorial

preview_player
Показать описание
In this C programming language video tutorial / lecture for beginners video series, you will learn about unary operator sizeof() in c in detail with example.

Tutorial explains why the sizeof is used, how to use it, what are the parameters required, how to use it to get the sizeof int, float and char variable and then integer, float and char datatype.
And then it explains the usage with structures, and addresses the issues like structure alignment,why compiler does structure alignment, how the structure alignment is done by the compiler.

Learn Programming in HINDI at our youtube channel

Catch us on Social Media
Рекомендации по теме
Комментарии
Автор

I know no body is going to reply but it still worth a shot. When i use odd no. in structure at the hgher place in array size it add 2 to output size, for even it gives real size.
For example if i was using an array of size 20 and an integer the output of size of will be 24, but when i use array of size 10 the output is 16.
Here is the source code you can try also between i'm using code block compiler.
#include<stdio.h>
struct football{
char name[20];
int goal;
}Messi;
int main()
{
printf("%d", sizeof(Messi));
return 0;
}

aakash
Автор

#include<stdio.h>
int main()
{
long long int a[10];
printf("%lld", sizeof(a));
return 0;
}
Sir why %lld giving wrong answer but if i replace it with %d it gives correct size which is 80.
%lld is also a place holder for integer.

aakash
Автор

the structure is adding additional bytes because of bit-field concept

JayPatel-etvi