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

ความคิดเห็น • 129

  • @saibalam7852
    @saibalam7852 3 ปีที่แล้ว +76

    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

  • @suryaganeshpindiprolu472
    @suryaganeshpindiprolu472 2 ปีที่แล้ว +15

    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 😄.

  • @pranavsood2767
    @pranavsood2767 3 ปีที่แล้ว +20

    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.

  • @abdulrahimjalloh363
    @abdulrahimjalloh363 ปีที่แล้ว +2

    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.

  • @balaguruvarafhasrinivasalu6668
    @balaguruvarafhasrinivasalu6668 2 ปีที่แล้ว +4

    Hi Jenny ,you have prepared very well and do lecture in a elegant and detailed explanation.I like your way of teaching .Thanks sister

  • @wankhademihir2859
    @wankhademihir2859 3 ปีที่แล้ว +2

    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

  • @shivanshuraj2894
    @shivanshuraj2894 ปีที่แล้ว +1

    mam there is no teacher like you. your teaching style make me big fan of you love from heart..❣❣

  • @sivajilaveti7308
    @sivajilaveti7308 3 ปีที่แล้ว +6

    From ANDHARA PRADESH 💞🥰

  • @मिठाईलालयादव-ङ1ह
    @मिठाईलालयादव-ङ1ह 3 ปีที่แล้ว +2

    Mam I'm currently doing job
    But now I have decided I wil study and try to understand u

  • @prathmeshyennawar9547
    @prathmeshyennawar9547 2 ปีที่แล้ว +1

    Awesome It just clear the concept

  • @ankitchaturvedi2941
    @ankitchaturvedi2941 ปีที่แล้ว +2

    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

    • @Ebookstore..
      @Ebookstore.. 9 หลายเดือนก่อน

      had the same doubt..i do think so it ahould be decreasing order itself

  • @ravirajbhar2896
    @ravirajbhar2896 3 ปีที่แล้ว +3

    Love you mam 😘😘

  • @educationforme
    @educationforme 20 วันที่ผ่านมา

    thank you so much ma'am very well explained🙏🏻🙏🏻

  • @cosmoky_19
    @cosmoky_19 ปีที่แล้ว +1

    amazing ma'am, thank you sooooooooooo muchhhhh for teaching such deep topics.

  • @VIJAYPARMAR-ot4hw
    @VIJAYPARMAR-ot4hw 3 ปีที่แล้ว +1

    Jayanti mam I love u your teaching habit

  • @mfaiz226
    @mfaiz226 3 ปีที่แล้ว +1

    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

  • @VMANFdo
    @VMANFdo 4 หลายเดือนก่อน

    Well explained thank you madam

  • @debojitacharjee
    @debojitacharjee 2 ปีที่แล้ว +3

    *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?

  • @shanmukhganesh4504
    @shanmukhganesh4504 2 ปีที่แล้ว +1

    Thank you so much Jenny mam

  • @anujeetkunturkar780
    @anujeetkunturkar780 3 ปีที่แล้ว +6

    Lecture Starts at 2:15

  • @abhishektomar1785
    @abhishektomar1785 2 ปีที่แล้ว +1

    Increasing or decreasing order

  • @asadjan1001
    @asadjan1001 3 ปีที่แล้ว

    Hi mam I am from Pakistan ur teach style is very well

  • @ayushgemini
    @ayushgemini หลายเดือนก่อน

    Modern processors are byte-addressable, not word-addressable.

  • @ankammaraochintala2509
    @ankammaraochintala2509 3 ปีที่แล้ว +1

    thank you madam

  • @kulkarnisoham
    @kulkarnisoham 3 ปีที่แล้ว +1

    I m following this playlist... I hope I get here soon 😅😅

  • @programmerdesire
    @programmerdesire 2 ปีที่แล้ว

    awesome mam noone tell be about this concept

  • @rakesh231rakesh
    @rakesh231rakesh 3 ปีที่แล้ว +1

    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.

  • @monishap9330
    @monishap9330 ปีที่แล้ว

    Thank you so much ❤

  • @riyagupta1841
    @riyagupta1841 3 ปีที่แล้ว +5

    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 🙏😄

  • @GaurikaDreamer
    @GaurikaDreamer 3 ปีที่แล้ว

    I proud of you 👏

  • @jony-s5m
    @jony-s5m 3 ปีที่แล้ว +1

    I am big fan mam

  • @leemajelifa5489
    @leemajelifa5489 2 ปีที่แล้ว

    I really love your explanation.❤

  • @cepheus6435
    @cepheus6435 2 ปีที่แล้ว

    thanks maam

  • @Mr_Pirates
    @Mr_Pirates 3 ปีที่แล้ว +2

    Third Like Mam.Love From Andhrapradesh..

  • @keshorkumar2085
    @keshorkumar2085 3 ปีที่แล้ว

    Mam your videos are very useful

  • @kanupriyasharma8741
    @kanupriyasharma8741 ปีที่แล้ว +1

    is structure padding only for structures or all codes(in void main int a ,char etc)?

  • @PRAMODLUCKYTECH
    @PRAMODLUCKYTECH 3 ปีที่แล้ว

    Good

  • @divyap6553
    @divyap6553 3 ปีที่แล้ว +2

    Mam please complete DBMS and DAA mam

  • @meetbhatt2113
    @meetbhatt2113 ปีที่แล้ว

    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

  • @DEVESH_BARAIYA
    @DEVESH_BARAIYA 3 ปีที่แล้ว +1

    Ma'am please c++ ki series start karen....plzzz...aap bhut achha padhati h...muje aap se padhna h..

    • @coding1415
      @coding1415 3 ปีที่แล้ว

      th-cam.com/video/dKVzZk4Pr2A/w-d-xo.html C++

  • @vakitiarchana6376
    @vakitiarchana6376 2 ปีที่แล้ว

    Mam explain structure and functions ,enumerated datatype

  • @ADITYAKUMAR-mf4po
    @ADITYAKUMAR-mf4po 7 หลายเดือนก่อน

    class Example {
    char c;
    int i;
    short s;
    }; what will be the total size for this ?

  • @boyasurendra4886
    @boyasurendra4886 2 ปีที่แล้ว

    Jenny please make a video about how to avoid padding most important question in interviews

  • @chakravarthipinninti3593
    @chakravarthipinninti3593 3 ปีที่แล้ว

    Please do a class on dynamic memory allocation

  • @gopalagarwal5383
    @gopalagarwal5383 3 ปีที่แล้ว

    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.

  • @nandhagopal9304
    @nandhagopal9304 3 ปีที่แล้ว

    Mam also teach enum and file handling

  • @jeejovetharaj5777
    @jeejovetharaj5777 ปีที่แล้ว

    if there is only char c in a structure, it should assign 4 byte of memory. but when executing it gives only 1 byte???

  • @Akash-gl6os
    @Akash-gl6os ปีที่แล้ว

    Ma'am how many memory will be allocated for double and long ,i mean how many data cycles ?

  • @sanjanapanwar3844
    @sanjanapanwar3844 3 ปีที่แล้ว

    ❤❤❤❤❤

  • @ravirajbhar2896
    @ravirajbhar2896 3 ปีที่แล้ว

    ❤️❤️❤️❤️

  • @franclinpereira8494
    @franclinpereira8494 2 ปีที่แล้ว

    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.

    • @franclinpereira8494
      @franclinpereira8494 2 ปีที่แล้ว

      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.

  • @coloringfunn
    @coloringfunn 3 ปีที่แล้ว

    I am here just to say....😍😍

  • @Heisenberg-pr1hk
    @Heisenberg-pr1hk 2 ปีที่แล้ว +2

    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 ?

    • @monarchofaether
      @monarchofaether ปีที่แล้ว +1

      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,

  • @najmuschowdhury1766
    @najmuschowdhury1766 3 ปีที่แล้ว

    Nothing but respect for you. Thank you for makin all of our lives easier. Amazing work!

  • @lucky_girl9715
    @lucky_girl9715 3 ปีที่แล้ว

  • @Parimala-t1w
    @Parimala-t1w หลายเดือนก่อน

    Mam What if we write
    typedef struct student student?

  • @varunkumardharmapuri7136
    @varunkumardharmapuri7136 3 ปีที่แล้ว

    Madam can you please give one lecture about DMA, storage classes in c .

  • @EmpowerKnowledge00
    @EmpowerKnowledge00 ปีที่แล้ว

    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.

    • @CHINMAYAM-p9i
      @CHINMAYAM-p9i ปีที่แล้ว

      nope for int 4 bytes and char has 1 byte remaining 3 are padding and other int has 4 bytes totally 12 bytes

  • @cherishvuppala8251
    @cherishvuppala8251 15 วันที่ผ่านมา

    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.

  • @CarlJohnson-bf8dq
    @CarlJohnson-bf8dq ปีที่แล้ว

    if i take double with 2 char so how padding would done?

  • @ankitchaturvedi2941
    @ankitchaturvedi2941 ปีที่แล้ว +1

    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.

    • @monarchofaether
      @monarchofaether ปีที่แล้ว

      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

    • @ankitchaturvedi2941
      @ankitchaturvedi2941 ปีที่แล้ว

      @@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

  • @akhilmittal3283
    @akhilmittal3283 3 ปีที่แล้ว

    superrrrbbbbbbbbbbb mam g

  • @chinnababu1483
    @chinnababu1483 3 ปีที่แล้ว +1

    #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?

  • @ganeshvarma3142
    @ganeshvarma3142 2 ปีที่แล้ว

    Mam if we use float

  • @nilayyyyyy1655
    @nilayyyyyy1655 3 ปีที่แล้ว +1

    Mam Plzzz Upload video of N Queen Problem by backtracking.........

  • @CryptoMaN_Rahul
    @CryptoMaN_Rahul 2 ปีที่แล้ว

    save memory save computer

  • @YugPosia
    @YugPosia 2 ปีที่แล้ว

    7:32

  • @chandands7218
    @chandands7218 2 ปีที่แล้ว

    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

    • @franclinpereira8494
      @franclinpereira8494 2 ปีที่แล้ว

      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.

  • @asrupa7163
    @asrupa7163 3 ปีที่แล้ว +1

    I love you 💖 mam appko dak ka fidda hogiya

  • @WaidsYT
    @WaidsYT 3 ปีที่แล้ว +1

    Java, Android tutorial start Karo plzz

  • @Rajveersingh-ix9uy
    @Rajveersingh-ix9uy 2 ปีที่แล้ว

    mam nested structure nhi pdhaye hai please ak video bna degeye

  • @hemanthsrinivasballa1243
    @hemanthsrinivasballa1243 ปีที่แล้ว

    Can a 32byte processor also allocate 4-4-4- bytes memory? 🤔

  • @NDGAMINGYT9968
    @NDGAMINGYT9968 2 ปีที่แล้ว

    Mam how can we see it on a program

  • @mfaiz226
    @mfaiz226 3 ปีที่แล้ว

    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

    • @mfaiz226
      @mfaiz226 3 ปีที่แล้ว

      Love From Pakistan.

  • @abhishekpandey0858
    @abhishekpandey0858 3 ปีที่แล้ว

    Mam your all c program is available in the chanal

  • @asrupa7163
    @asrupa7163 3 ปีที่แล้ว +1

    I love you ❣️ I like you 😍 I miss you 😘

  • @kanhasharma2500
    @kanhasharma2500 2 ปีที่แล้ว

    I have same size with structure padding and packing
    I have size of structure packing mam
    Solve issue

  • @DonsT199
    @DonsT199 3 ปีที่แล้ว

    Madam Please Teach About LAMBDAS in C .... and C ++ ... Please Mam....

    • @coding1415
      @coding1415 3 ปีที่แล้ว

      th-cam.com/video/dKVzZk4Pr2A/w-d-xo.html C++

  • @arafathdhroba8897
    @arafathdhroba8897 2 ปีที่แล้ว

    struct zzz{
    int k;
    int c;
    char d;
    }n;
    why i am getting the size 12 ,instead of 16 in a 64 bit machine??

    • @CHINMAYAM-p9i
      @CHINMAYAM-p9i ปีที่แล้ว +1

      nope for int 4 bytes and char has 1 byte remaining 3 are padding and other int has 4 bytes totally 12 bytes

  • @shivpalchaudhary-rq4ed
    @shivpalchaudhary-rq4ed ปีที่แล้ว +1

    You are so beautiful

  • @TheLinKueiWarrior
    @TheLinKueiWarrior 3 ปีที่แล้ว

    ok we are done with DS now start C# and Kotlin

  • @jitendratiwari4292
    @jitendratiwari4292 3 ปีที่แล้ว

    Maddam je , can you explain master detail relationship plz in hindi 🙏🙏🙏🙏🙏🙏

  • @ankithamr4912
    @ankithamr4912 3 ปีที่แล้ว

    Mam could you plz cover files in c mam please

  • @jaikishankumar3377
    @jaikishankumar3377 3 ปีที่แล้ว

    Very interesting. Could you please do the lectures on design patterns also?

  • @harshgupta7526
    @harshgupta7526 3 ปีที่แล้ว

    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.

  • @svb7555
    @svb7555 3 ปีที่แล้ว

    JAVA bhi sikhao na....pls

  • @abhaytiwary2981
    @abhaytiwary2981 7 หลายเดือนก่อน

    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.

    • @SamSam-ny9nf
      @SamSam-ny9nf 6 หลายเดือนก่อน

      Larger data type is 1byte. So it will take 2 bytes. Both are char.

    • @shashwatmangulkar1107
      @shashwatmangulkar1107 6 หลายเดือนก่อน

      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

  • @Music.Music.3D
    @Music.Music.3D 3 ปีที่แล้ว +1

    first view ma'am

  • @godasujaswanthsivaji9765
    @godasujaswanthsivaji9765 3 ปีที่แล้ว +2

    You are beautiful mam

  • @jony-s5m
    @jony-s5m 3 ปีที่แล้ว +1

    And your subject

  • @bibekranjanmajhi5564
    @bibekranjanmajhi5564 3 ปีที่แล้ว +1

    My life is full of obstacles. (family,money and gf mrg proposal) mam... I am unable to understand everything. Help me mam please😫😫😫

  • @tonupif
    @tonupif 2 ปีที่แล้ว

    Нормально прогнала за выравнивание, но английский, конечно, очень смешной.

  • @mohitnama2158
    @mohitnama2158 ปีที่แล้ว

    I am failed in this question........ I'm watching it too late 😭😭

  • @umangpanday8321
    @umangpanday8321 3 ปีที่แล้ว

    Good evening ma'am Iam in class 9 .
    I see all your videos for information.

  • @sadacaif4273
    @sadacaif4273 3 ปีที่แล้ว

    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..

  • @williamsoeparman1510
    @williamsoeparman1510 3 ปีที่แล้ว

    Excuse me ms, im from indonesia. if possible please include indonesian subtitle. Im not good at english.

  • @sanjaykumarrana6312
    @sanjaykumarrana6312 ปีที่แล้ว

    Love 💕 😘 you jennis, agar tum mil jao jamana chod denge ham

  • @asrupa7163
    @asrupa7163 3 ปีที่แล้ว +1

    Mam app bohut sundor ho apki marriage hogiya ?

  • @DevanshPrajapati
    @DevanshPrajapati 3 ปีที่แล้ว +1

    Mam English itni achi nahi hai Aap Hindi Wali channel Alag se banaye.

  • @Israr_Ayoub
    @Israr_Ayoub 3 ปีที่แล้ว

    Hi mam iam the first who is watching your new video plz if u read my comment plz mention me