C_116 Structure Padding in C | C Language Tutorials
ฝัง
- เผยแพร่เมื่อ 7 ก.พ. 2025
- C complete playlist: • Programming in C
Use my code JKL10 to get 10% discount:
Batch Link: unacademy.com/...
Connect & Contact Me:
Vlogging Channel Link: bit.ly/354n7C7
Facebook: / jennys-lectures-csit-n...
Quora: www.quora.com/...
Instagram: / jayantikhatrilamba
Twitter: / khatrijenny
See Complete Playlists:
Placement Series: • Placements Series
Data Structures and Algorithms: https: • Data Structures and Al...
Design and Analysis of Algorithms(DAA): • Design and Analysis of...
Dynamic Programming: • Dynamic Programming
Operating Systems: // • Operating Systems
DBMS: • DBMS (Database Managem...
#StructurePaddinginC
#StructuresinC
#CProgrammingTutorialsforbeginners
#jennyslectures
If there is no Jenny's lectures I definitely quit from CS DEPARTMENT BUT NOW I can't quit from this because I ❤️ MY CS DEPT BECAUSE OF JENNY MAM MY BEST CODING GURU TQ SO MUCH MAM
Wah anna waah..🎉
Teaching everything you have for free is really appreciable. Can you please make a video on your coding journey and how you got into youtube . Thank you again 😄.
don't focus your attention on the negative comments mam, coz it's just a distraction. Most of your fan base love your work and are grateful for you to do this here.
Mam, you are a blessing to us, your lectures helped me in my exam, and i got A+ in C programming. It is not about the grade, but the understanding, you are making me understand C, and this is good for me as a beginner. Thanks mam.
Hi Jenny ,you have prepared very well and do lecture in a elegant and detailed explanation.I like your way of teaching .Thanks sister
I'm from Mars, your videos helped me a lot :D
Well jokes apart, you're helping hundreds and thousands one night before ecams. Thanks lot
mam there is no teacher like you. your teaching style make me big fan of you love from heart..❣❣
From ANDHARA PRADESH 💞🥰
Mam I'm currently doing job
But now I have decided I wil study and try to understand u
Awesome It just clear the concept
instead of increasing decreasing will more reduce size e.g - int a,char b then 4 byte will take at 0 to 3 and char will place at 4 so total will be 5 where in increasing it is 6
had the same doubt..i do think so it ahould be decreasing order itself
Love you mam 😘😘
thank you so much ma'am very well explained🙏🏻🙏🏻
amazing ma'am, thank you sooooooooooo muchhhhh for teaching such deep topics.
Jayanti mam I love u your teaching habit
Hi Ma"am. Hope you will be doing Great.I am your biggest fan. I love the way you speak, the way you deliver the Lectures.
We understand it Very Very.... Well. keep doing it . Thanx
Well explained thank you madam
*WHY IT WILL NOT TAKE 2 CYCLES?* - in the total 8 bytes of memory stack, if total 5 bytes are required for 2 variables (1 int + 1 char) then to process 5 bytes from any location, 2 times the memory has to be accessed if the system can access only 4 bytes at one time. So how does it make sense to use 1 bytes first and 4 bytes at last of the memory stack?
Thank you so much Jenny mam
Lecture Starts at 2:15
Increasing or decreasing order
Hi mam I am from Pakistan ur teach style is very well
Modern processors are byte-addressable, not word-addressable.
thank you madam
I m following this playlist... I hope I get here soon 😅😅
awesome mam noone tell be about this concept
One thing is missing, to reduce memory wastage one should always use packing rather than writing elements in increasing order of their size. CPU cycles does not matter.
Thank you so much ❤
Mam after structure packing pls cover enum, malloc, calloc, realloc !
Don't forget to cover these topics mam pls 🥺😕
You have also replied on my comment "Okie" so pls don't forget to cover these topics mam please pls 🙏😄
I proud of you 👏
I am big fan mam
I really love your explanation.❤
thanks maam
Third Like Mam.Love From Andhrapradesh..
Mam your videos are very useful
is structure padding only for structures or all codes(in void main int a ,char etc)?
Good
Mam please complete DBMS and DAA mam
hello mam, Thankyou for give answer of what is padding beacause of this question asked in my interview and unfortunately i don't know then after i search on youtube/google and after this i found this video
Ma'am please c++ ki series start karen....plzzz...aap bhut achha padhati h...muje aap se padhna h..
th-cam.com/video/dKVzZk4Pr2A/w-d-xo.html C++
Mam explain structure and functions ,enumerated datatype
class Example {
char c;
int i;
short s;
}; what will be the total size for this ?
Jenny please make a video about how to avoid padding most important question in interviews
Please do a class on dynamic memory allocation
ma'am at 12:35 using the same datatype in structure members is an error said by you in previous videos...Kindly clarify my doubt why you have written the same data type. Thank you.
Mam also teach enum and file handling
if there is only char c in a structure, it should assign 4 byte of memory. but when executing it gives only 1 byte???
Ma'am how many memory will be allocated for double and long ,i mean how many data cycles ?
❤❤❤❤❤
❤️❤️❤️❤️
Thank you mam, but there is one correction... Don't blame you,just want to help people..
There is little different theory...for padding
Let's take example: struct { double , char}
as per this logic on 64 bit machine, answer will be 8+1+3(padding)=12.
But Padding happens of the highest data type, like in our case highest is 8 byte, so next it reads as same byte(if there is less it will pad), so
8 + 1+7(padding)
If there are more variables then too it will keep padding to make it 8byte...
I don't blame Jenny but looks she missed something,btw she is doing the great job.
Please do try
{Double , int}
{Int , char}
{*p , char}
{Long double, char}
You will observe the results...
I am not here to criticize anyone.. I started learning from Jenny mam,n I respect her.
I am here just to say....😍😍
I defined int,char,int in 64 byte computer. I expected sizeof this struct 16 byte but it was 12 byte. 4(int) + 1(char) + 3(blank) + 4(int) = 12byte. Why is it like this ? Shouldn't take also 4 byte ?
I have also been asking the question but it is mostly ignored. What I found out from research is that compiler sometimes perform additional optimizations or the compiler settings may be affecting the structure behaviour, Compiler behavior can vary, so it's worth checking the documentation or specific compiler settings to understand the exact behavior in your case
Often the structure will be aligned to the size of the largest member in the struct, so because the strict has int the max size of a member is 4 bytes and the struct is 4-bye aligned as a result. 🙂
this was the situation in my case, I confirmed this by iincluding a long datatype and the size became 24 meaning the compiler made the byte-alignment according to the largest member of the struct, if not I should have gotten 20 instead for a 4-byte alignment,
Nothing but respect for you. Thank you for makin all of our lives easier. Amazing work!
❤
Mam What if we write
typedef struct student student?
Madam can you please give one lecture about DMA, storage classes in c .
Please answer,
#include
Struct abc{
Int a;
Char b;
Int c;
}var;
Void main() {
Printf("%d bytes", sizeof(var));
}
Output : 12 bytes
Whereas i am expecting the output to be "16 bytes" [4bytes(for a)+1bytes(for b)+3bytes(padding)+4bytes(for c)+4bytes(padding)] coz my system is of 64bit and word size has to be of 8bytes.
nope for int 4 bytes and char has 1 byte remaining 3 are padding and other int has 4 bytes totally 12 bytes
Ma'am, I learning structure padding and seen your lecture, I have doubt for this code typedef struct structc_tag {
char c;
double d;
int s;
} structc_t; I have calculated the size as 16 (char - 1byte + 3bytes padding + 8bytes + 4bytes ), but in gfg it was given 24, I didn't understand how and I have gone through the explaination still I'm confused!, could you please clarify this ma'am.
if i take double with 2 char so how padding would done?
how padding reduce cpu cycle or increase speed as it will take 2 cycle for int and char , without padding it was taking 2 cycle so how it increase speed.
yeah, I think she made a mistake because in both instances it would still take 2 cycles for a 4-byte word addressing, but at the end of the day I guess she explained the concept well and explained it properly when she used three members at 12:35 (char, int, char) for the structure
@@monarchofaether actually she is right , i learnt after that many resources actually, if we only want to use either char or int without padding then cpu will process 1 cycle for 2 byte another cycle for remaining 2 byte int which is stored in anothee 8 byte address, but if you use padding then all byte of either int or char will be on one 8 byte address storage so if you only need to access int then it will run 1 cpu cycle. you can understand it as for accessing only one variable data type it is faster other wise we have to run unnecessary cycle
superrrrbbbbbbbbbbb mam g
#Q Thank you for info. After structure padding may I know the process of data reading happen correct way.colud you please explain the process of read in unaligned and aligned structure?
Mam if we use float
Mam Plzzz Upload video of N Queen Problem by backtracking.........
save memory save computer
7:32
Structure s
{
Char *ptr;
Char c;
};
Size of structure in 32bit compiler it's giving size as 16,
Why not size is 12( 8 for pointer, 4 for char), it's word size is 4 right, so why not multiple of 4 size is not there
There is little different theory...bro, I got to know today...
Padding happens of the highest data type, like in your case highest is 8 byte, so next it reads as same byte, so
8 + 1+7(padding)
I don't blame Jenny but looks she missed something,btw she is doing the great job.
I love you 💖 mam appko dak ka fidda hogiya
Java, Android tutorial start Karo plzz
mam nested structure nhi pdhaye hai please ak video bna degeye
Can a 32byte processor also allocate 4-4-4- bytes memory? 🤔
Mam how can we see it on a program
Ma'am, Theory Of Automata py bhi Series baneaya Ga.Ma na boht search kia tha lekin boht moshkil .
agar aap koi youtube channel ya notes etc share kardein.barii mehrobani hogi....thank you
Love From Pakistan.
Mam your all c program is available in the chanal
I love you ❣️ I like you 😍 I miss you 😘
I have same size with structure padding and packing
I have size of structure packing mam
Solve issue
Madam Please Teach About LAMBDAS in C .... and C ++ ... Please Mam....
th-cam.com/video/dKVzZk4Pr2A/w-d-xo.html C++
struct zzz{
int k;
int c;
char d;
}n;
why i am getting the size 12 ,instead of 16 in a 64 bit machine??
nope for int 4 bytes and char has 1 byte remaining 3 are padding and other int has 4 bytes totally 12 bytes
You are so beautiful
ok we are done with DS now start C# and Kotlin
Maddam je , can you explain master detail relationship plz in hindi 🙏🙏🙏🙏🙏🙏
Mam could you plz cover files in c mam please
Very interesting. Could you please do the lectures on design patterns also?
mam . when will start oops concepts , it is very important for us , please tell me mam , I am waiting your reply , please please mam , I humbly request to you.
JAVA bhi sikhao na....pls
struct abc {
char a;
char b;
}var;
For 32 bit processor (4 bytes word size)
sizeof(var) should be 4 bytes
but, I am getting result 2 bytes on my laptop after running this program.
If someone can answer, then please answer this.
Larger data type is 1byte. So it will take 2 bytes. Both are char.
sizeof() is the memory in bytes used from the allocated
allocated is the separated memory for that paticular struct. so ig it's showing you the memory used by the struct abc
first view ma'am
You are beautiful mam
And your subject
My life is full of obstacles. (family,money and gf mrg proposal) mam... I am unable to understand everything. Help me mam please😫😫😫
Нормально прогнала за выравнивание, но английский, конечно, очень смешной.
I am failed in this question........ I'm watching it too late 😭😭
Good evening ma'am Iam in class 9 .
I see all your videos for information.
Ma'am agar aap ye comment padh rahi hai to please btaye 🙂
Programming sikhne ke liye English aana zaruri hai aur computer ka student hona zaruri h..
Excuse me ms, im from indonesia. if possible please include indonesian subtitle. Im not good at english.
Love 💕 😘 you jennis, agar tum mil jao jamana chod denge ham
Mam app bohut sundor ho apki marriage hogiya ?
Mam English itni achi nahi hai Aap Hindi Wali channel Alag se banaye.
Hi mam iam the first who is watching your new video plz if u read my comment plz mention me