speachless!! you are soooo goood in explainging. thanks a lot
@koperaljali32534 жыл бұрын
Yes agree.
@John-sl5zz2 жыл бұрын
your style of pedagogy has helped me in overcoming phobia of coding. the sort of knowledge you are imparting is enriching our lives. thanx a ton & we look forward to having more such amazing content. kudos to you.
@devugoel86982 жыл бұрын
This was the best. Saw many tutorials, but understood the concept here in one go. I rarely comment on videos, but really had to appreciate you here. Thanks man!
@عليكيلاني-ي8د Жыл бұрын
I couldn't agree with you more , It's awesome how he explained it.
@WistrelChianti4 жыл бұрын
Brilliant! I particularly liked the repetition when driving home a particularly important point. Superb work (and exactly what I was looking for - was searching for a good detailed explanation on structure storage in memory).
@manazirahsan13512 жыл бұрын
Tnx
@andresvallelisboa55114 жыл бұрын
Thank you very much! I understood it. I Love the format you chose for the video, a black background, a representation of the memory bytes and everything was explained in a very direct and simple way.
@manazirahsan13512 жыл бұрын
Ok
@anshhmehta2 жыл бұрын
Perfect video to understand the importance of padding and its uses.
@dono42 Жыл бұрын
Padding is not defined in the C (or C++) standard. This behavior depends on the compiler. It can also be configured too. For example, VC++ has the /Zp and #pragma pack options while GCC has -fpack-struct option.
@manoharbompella4183 жыл бұрын
Explained very detailed, Cleared every doubt. Thank you
@sunilkumarreddy65375 жыл бұрын
Sir it is a good class for me. Thank you sir,upto now I didn't no the background allocation of memory now I got clarified. SIR ONE MORE THING, I WANT TO sll,dll,cll,sporting techniques tree's,graphs,bss. Pls... upload sir, one of ur student, thank you sir.
@manuelconte21272 жыл бұрын
It is a good habit to put first the biggest type in ascending order to help compilator !
@michaelhernandez2075 Жыл бұрын
trying to read how this works is way harder than having pictures and someone explaining. Thank you.
@beeyou62202 жыл бұрын
I m having 8 yrs of experience. Noone Clarified the doubt lk u..thank you..expecting more content from you
@rakesh231rakesh2 жыл бұрын
😱
@adeshgaikwad21925 жыл бұрын
Thank you sir for clearing the concept in such an easy way...
@andistheinforitbutso75132 жыл бұрын
Awesome work 👏 Lesson: we should be careful while arranging the srruct variables for better memory utilisation
@pnuema1.6182 жыл бұрын
Padding also becomes a portability issue when code is written on a system with different architecture then the architecture it is being run on. If you already knew this then my apologies. I just feel like understanding padding has more to do with writing portable code.
@TechnoVisionTV2 жыл бұрын
Such an amazing explanation! You made it so simple to understand, thank you :)
@sujitsatpute37413 жыл бұрын
You are explaining 💯 times better than my college professor......
@SJ_462 жыл бұрын
1000 bro
@ArjanvanVught5 жыл бұрын
Missing to explain __attribute__((packed)) with unaligned memory access which is possible (with ARM).
@ivanleon61643 жыл бұрын
#pragma pack(1)
@nishantraj50204 жыл бұрын
you make every concept so easyyyyyyyyy.
@khoahuynh68842 жыл бұрын
It is always the Indian sensei that makes me understand.
@mcbotface5 жыл бұрын
Thank you sir. Keep posting more on stacks, queues, linked lists
@santanacasas12 жыл бұрын
Excellent explanation, thanks for your dedicated time in creating these videos. Regards from Mexico.
@paschikshehu79883 жыл бұрын
1:15 not necessarily wrong, just that 1-packing is not efficient
@05_abhisheksharma133 жыл бұрын
Amazing initiative by neso academy
@ronnieahabwomugisha52835 жыл бұрын
its has been clear. thanks Sir
@priyaj99084 жыл бұрын
Very useful video...Thank you sir.please try to put more videos in advanced c topics..
@rajmishra67695 жыл бұрын
Thanks for the wonderful explanation.
@あまね-y6t4 жыл бұрын
really easy to understand for me. thanks a lot!!
@vijaykounsalye5 жыл бұрын
just awesome bro you have explained very well
@y_red_gold_a42802 жыл бұрын
Best explanation of the concept. Thank you so much.
@mikestock18485 ай бұрын
Awesome explanation, thanks for sharing
@dhruvsakariya31292 жыл бұрын
perfect example of 32byte and 64 byte difference thank you very much sir
@adithyay3284 жыл бұрын
Good, clear explanation!
@pnuema1.6182 жыл бұрын
You are one of my favorite sources for c programming concepts. I know that if you have a video on the subject then I will be able to understand that concept. Thank you!
@manazirahsan13512 жыл бұрын
Ok
@mdkamrankhan40325 жыл бұрын
Great explanation Sir..
@leepakshiyadav16432 жыл бұрын
crystal clear explanation, thanks a lot :)
@somuseth4 жыл бұрын
4:40 Sir, does it mean that total of 3 cyles are required to access the 3 variables???
@kumard-n9m4 жыл бұрын
Yes
@pranavkshirsagar1464 жыл бұрын
Barney Stinson was their... I got so happy after seeing him😆😆
@VivekYadav-ds8oz3 жыл бұрын
Why is the compiler not allowed to rearrange member variables? If there's a consistent rule for this, then even external libraries will not face any ambiguity. That way, int variable could've been placed in front, and no wastage will be required and all 3 can be accessed in one CPU cycle.
@excite2362 жыл бұрын
Have you tried enabling optimizations with your compiler?
@premithagoni8634 Жыл бұрын
Awesome Explanation sir,Thank you
@Aabara_ka_dabara Жыл бұрын
something unique and new things I have learned💕💕
@QuratulainAzhar7 ай бұрын
Amazing 🤩
@jishankhan66863 жыл бұрын
You are really great. Plzz. Give a practical example nd make us clear how a software execute. Suppose i have one software on my mobile then how this software will be executed. Plz give us practical example from first to last.
@rakurame69902 жыл бұрын
Good explanation on structure padding
@multivalfran2 жыл бұрын
Excellent video my friend
@rohiths-k2d Жыл бұрын
excellent lecture i have ever seen
@vishnu54663 жыл бұрын
Very Interesting!...
@mudassar20122 жыл бұрын
very helpful video.....so good explanation
@RozgarBharatIT Жыл бұрын
Great Explanation!!
@amandarash1355 жыл бұрын
Best explanation
@umairalvi73825 жыл бұрын
Considering the processor is of 32-bit Void main () { char a; } then in the memory for the variable a, only 1 byte will be allocated, then how the processor will request this memory using word...without padding?
@bharathiapps82303 жыл бұрын
The processor would read 4 bytes(from the address of variable char a, it will use only the first byte ), a 32 bit processor always reads 4 bytes(memory is 4 bytes aligned).
@nileshpokale8623 жыл бұрын
Excellent Explanation. All cleared
@donythomas72 жыл бұрын
Excellent explanation 👍
@sohitgore29242 жыл бұрын
To handle the case where the memory words are in different memory pages the processor must either verify that both pages are present before executing the instruction or be able to handle a TLB miss or a page fault on any memory access during the instruction execution. Source - Wikipedia
@avronilbanerjee53022 жыл бұрын
excellent explanation
@kitanowitsch2 жыл бұрын
For example, with ARM architecture (it's 8bit addressable and 32 bit accessible) engineers and programmers are encouraged to use 32 bit values all the time, so software will run faster and more secure. If memory space is critical then optimization is needed.
@rakesh231rakesh2 жыл бұрын
It is all about time and space.
@gamerplayer948303 ай бұрын
What does addressable and accessable mean? and what is the difference could you please tell? couldnt find or understand from anywhere
@kitanowitsch3 ай бұрын
@@gamerplayer94830 When you write and when you read from the memory, respectively. Data is written by 8 bits into the memory and read by 32 bits. So if your 8 bit data is in 4th memory part of 32bit location, it will take 4 tries to access that particular byte. That's why it is important when you declare structs and any other type of data. More speed and more secure.
@gamerplayer948303 ай бұрын
@@kitanowitsch thank you very much, i understood! have a nice day
@kunalsoni76815 жыл бұрын
wow great one presentation sir..
@revan76002 жыл бұрын
Very nice explanation thank you
@shreyasingh2223 жыл бұрын
Thank you so much for detailed explanation.....
@chandumadhumanthi99834 жыл бұрын
Excellent👍
@haripriyaraja18903 жыл бұрын
Nice clarification 😍
@aashishmalhotra Жыл бұрын
I'm wondering why bloody YT algo doesn't recommend your channel in first year.
@Siva-fl1sq10 ай бұрын
Same feeling..
@Vishall000189 ай бұрын
Also*
@kryptoniangaming60825 ай бұрын
Maybe they haven't done the right SEO
@elchurisrivarna29 күн бұрын
Same
@harshalgarg11493 жыл бұрын
Great explanation.
@JohnDoe-kj2cs3 жыл бұрын
Silky smooth!
@garapatianushadevi34273 жыл бұрын
Very good, just loved it
@ahmedsiraj27584 жыл бұрын
when declaring 3 char, it should give 4 as output, why giving 3
@jayaprakashthokala6404 жыл бұрын
Word size is nothing but highest size of a data type used...
@anandg40184 жыл бұрын
because 3 char are taking 3 bytes of size within the word, and word is actually 4 bytes long thats why it is showing 4 bytes as output
@ImtiazAhmedRatul4 жыл бұрын
The reason behind is is that all 3 chars can be accessed using 1 CPU cycle. In other words, for CPU to access char 1 will only take 1 cycle, char 2 will take 1 cycle and char 3 will take 1 cycle. Padding is introduced to save CPU cycles. Since there is no way to get fewer cycles than 1, the compiler doesn't introduce any padding. I understand your confusion. If the CPU is accessing 1 word (4 bytes) at a time, the struct should be char (1 byte + 3 padding) x 3 = 12 bytes in size. What word size the machine will use depends on the type of data it is trying to access. So if it's trying to access a char, it is using word size == 1byte. For int, it will use 4 bytes. When it sees a structure that has both, it will use the highest size (int == 4 in the video's case). In your case, it's using 1 byte for word size.
@0mer8703 жыл бұрын
@@ImtiazAhmedRatul It seems you misunderstood his logic. He didn't say it should allocate 12 bytes but 4 which is the word size for a 32 bit processor. And since the instructor said that the processor reads one word at a time and not 1 byte, you'd except it to be always so even if it was just a char it should get allocated 4 bytes as in "1 word at a time". Therefore I think that padding applies only when the size of the variable exceeds the size of a word.
@lawalayodeji40443 жыл бұрын
The null character \0 is 1 byte. It is always at the end of all char or int.
@Jose_T1312 жыл бұрын
Very well explained, thank you sir
@KrupaPrarthana9 ай бұрын
Wonderful ❤
@somasekhardakala26305 жыл бұрын
very nice explained....thank you sir 🤝.....
@aps_2693 жыл бұрын
Amazing, 😍😍
@093raselrahman43 жыл бұрын
Nothing to say ! Very easy explanation.
@shauryakumar2229 Жыл бұрын
Very helpful thanku
@mamtaCoder5 жыл бұрын
Thank you sir...😃😇
@Cat_Sterling4 жыл бұрын
That was just great! I was wondering about that for so long! But what is a "word" in computer architecture?
@zidanegimiga81803 жыл бұрын
A word must be 4 or 8 bytes long, depending on the computer architecture I guess.
@nikhilwagh1728 Жыл бұрын
Great video
@liangzhang17224 жыл бұрын
Life saving! Ty
@bharatbs71414 жыл бұрын
Very Helpfull...Thank You :)
@fidalgoverde4 жыл бұрын
Excellent job
@kirankumarkakileti28114 жыл бұрын
Awsome xplanation😍
@47-6F-644 жыл бұрын
Amazing
@yemreekinci8 ай бұрын
Adamsın kral çok güzel anlattın.
@ashwanirajput91412 жыл бұрын
If we declear one more "char" var outside of struct. Then memory allocation for that var is where. 1. Just after var C " 10th place ". 2. 13th place.
@chintanchatterjee9477 Жыл бұрын
Respected Sir, I have a doubt in one program of this topic. #include struct abc{ float a; double b; } var; int main() { printf(“%d”, sizeof(var)); return 0; } In 32-bit architecture, the output of the above code should be 12 if float size is 4 B and double size is 8 B. But in online compilers like onlinegdb, programiz, etc., the output of this particular code is 16. What is the reason? I am not getting it. Thanks and Regards. Chintan
@sushaanthsureshkumar11 ай бұрын
Ah you kind of got it wrong, It should be 16 bytes. In Sir's example int was the largest size taking value i.e. 4 bytes, (Alignment value) so have 2 fields char and char then having int will have a total size of 8 bytes. In your case, the largest is double which is 8 bytes. (Alignment value) You have float at first and then double meaning 8*2 = 16 bytes are reserved for your struct and its not 12 bytes. This C way of writing is also used Go. I'm not sure with C++ probably it too has this behavior. Happy Coding @chintanchatterjee9477
@gurlinkanaveenkumar72092 жыл бұрын
Tqu sir.
@FraPiz2 жыл бұрын
wow, my mind is blown
@winxkin60563 жыл бұрын
it is very helpful
@tanmayghosh83112 жыл бұрын
never thought we can optimize our code using this methods
@RezaulKarim-cq5ft3 жыл бұрын
amazing!
@anjani_tiwari Жыл бұрын
Dhanyavaad🙏
@yahyaaouledamer14662 жыл бұрын
amazing thanks so much
@krishnakumar-kh5vo2 жыл бұрын
well explained
@botelhocpp2 жыл бұрын
I was thinking... Sure, the processor can only access a word at a time. But wouldn't it make sense to, like, displace the address of the struct a bit to access the integer? Like, in the first example... Rather than padd the first word, wouldn't be better to just add 2 to the address and access the integer right away?? Or this operation would cost too much clock-wise everytime?
@andyprem3 жыл бұрын
excellent excellent explanation ..I was having an issue wstructure memebers being read incorrectly and I was suspecting this padding issue. and I was wondering how to explain this to the team .may be I should link to this vedio .. lol ;)
@silentcat42924 жыл бұрын
Crystal clear
@okavango59373 жыл бұрын
If the CPU accesses the addresses only in "word" sizes, then why is 'sizeof(char)' 1? It sould also be 4 (in 32bit) right?
@RAVITEJAP-ss9rl3 жыл бұрын
So if we have a variable of char type then it's size would be 4 bytes because that processor can access 4 bytes at a time, but it's not so why? Does this padding concept applicable for only stuctures? Can somebody explain....
@monarchofaether Жыл бұрын
I defined int,char,int in 64-bit 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 ?
@sushaanthsureshkumar11 ай бұрын
#include int64_t i2 = 0x0000444400004444LL; This is how you declare 64 bit integer. regular int is not special, it's 32bit i.e 4 bytes. In your problem the alignment value is 4 so 4*3=12 bytes.
@karthicknandhakumar2645 жыл бұрын
Sir, I understand the padding concept..but in 1st case , overall 2 cpu cycles are used with padding and without padding...then what is the use of having padding?
@abhishekrawat50965 жыл бұрын
Please watch video properly , the Instructor have already answered this , in 1st example , suppose you want to access (integer c) , then you will get it only in 1 cycle using "padding" and without padding concept , you have to get the same (integer c) in 2 cycles
@arshadshaik65544 жыл бұрын
@@abhishekrawat5096 yes, correct but in 1 st cycle, along with 2 bytes of int c, already two bytes (char a and char b) are accessed and in second cycle the remaining two bytes of int c are accessed. In this case, Anyway only two cycles are used with padding and also without padding, then what's the use of padding here??
@debabratamohapatra66384 жыл бұрын
@@arshadshaik6554 bro, sir then explained it, suppose u want to access only int c and not char a and b to do so, unnecessary 2 cycles will be wasted which can be done in one cycle using structure paddling. Hp u understood..
@rishabhjha75652 жыл бұрын
@@debabratamohapatra6638 thanks for clearing my doubt
@RahulRazj4 жыл бұрын
when declaring a char and then a double variable it should give 4+8=12 as output. But it shows 16. Can someone explain why?