C structs 🏠

Sdílet
Vložit
  • čas přidán 5. 10. 2021
  • C structs tutorial example explained
    #C #struct #structs
    struct Player
    {
    char name[12];
    int score;
    };
    int main()
    {
    // struct = collection of related members ("variables")
    // they can be of different data types
    // listed under one name in a block of memory
    // VERY SIMILAR to classes in other languages (but no methods)
    struct Player player1 = {"Bro", 4}
    struct Player player2 = {"Bra", 5}
    //strcpy(player1.name, "Bro");
    //player1.score = 4;
    //strcpy(player2.name, "Bra");
    //player2.score = 5;
    printf("%s
    ", player1.name);
    printf("%d
    ", player1.score);
    printf("%s
    ", player2.name);
    printf("%d
    ", player2.score);
    return 0;
    }
  • Věda a technologie

Komentáře • 49

  • @BroCodez
    @BroCodez  Před 2 lety +93

    #include
    #include
    struct Player
    {
    char name[12];
    int score;
    };
    int main()
    {
    // struct = collection of related members ("variables")
    // they can be of different data types
    // listed under one name in a block of memory
    // VERY SIMILAR to classes in other languages (but no methods)
    struct Player player1;
    struct Player player2;
    strcpy(player1.name, "Bro");
    player1.score = 4;
    strcpy(player2.name, "Bra");
    player2.score = 5;
    printf("%s
    ", player1.name);
    printf("%d
    ", player1.score);
    printf("%s
    ", player2.name);
    printf("%d
    ", player2.score);
    return 0;
    }

  • @hand-eye4517
    @hand-eye4517 Před rokem +75

    GREAT content , clear , concise , to the point. Mentioned other relevant material. Did not waste a ton of time Provided source code... Deserves a sub Thank you sir for your efforts.

  • @johnc3403
    @johnc3403 Před rokem +140

    Bra should have a h, otherwise it's just an over-the-shoulder boulder holder! ..apart from that, great video Bro, concise and easy to understand.

  • @NezarAhmed57
    @NezarAhmed57 Před 5 měsíci +12

    2:46 bra! what a coole name lmao
    thank you bro for the lesson, we appreciate your work

  • @techplayz06
    @techplayz06 Před 13 dny

    Very clear explanation! Thank you!

  • @Garrison86
    @Garrison86 Před 2 lety +7

    Amazing!! thanks for the clear explanation.

  • @GuedriaRayen
    @GuedriaRayen Před 8 měsíci +8

    poor player2, he didn't deserve such a name 😥

  • @pattyspanker8955
    @pattyspanker8955 Před 11 měsíci +3

    Yes, happy to see BroCode has a video on this

  • @user-kr1wc6kk8g
    @user-kr1wc6kk8g Před 4 měsíci +2

    that is nice presentation but please help us in structure and function related codes.thanks

  • @fo3musaib888
    @fo3musaib888 Před 9 měsíci +1

    great info

  • @wacky_aman
    @wacky_aman Před rokem +5

    omg i understood it in first try hehe, thank you bra XD

  • @sunstixy
    @sunstixy Před 8 měsíci

    Nice lesson, thanks ^^

  • @possiblyzslot838
    @possiblyzslot838 Před rokem +2

    Lifesaver.

  • @alpiinoo135
    @alpiinoo135 Před 8 měsíci

    Thanks!

  • @bikdigdaddy
    @bikdigdaddy Před rokem +1

    perfect, its concize.

  • @billyboone69
    @billyboone69 Před rokem +1

    Thanks Bro

  • @GrowthPulse509
    @GrowthPulse509 Před 2 lety +1

    Yo bro make a video on pointers plz

  • @r00tgod
    @r00tgod Před 2 lety

    ty

  • @ashvikvijai8114
    @ashvikvijai8114 Před 2 měsíci

    fire vid

  • @simonG-R.
    @simonG-R. Před rokem +1

    Thanks! it helped a lot.

  • @creepydog3903
    @creepydog3903 Před 9 měsíci

    thank you

  • @user-qy7pj8vz9n
    @user-qy7pj8vz9n Před 8 měsíci

    Nice

  • @yusraazrademirel2195
    @yusraazrademirel2195 Před rokem

    thanks

  • @dumbcat720
    @dumbcat720 Před rokem

    thanks bro meow

  • @denifer_
    @denifer_ Před 2 měsíci

    W

  • @naveenkumar1853
    @naveenkumar1853 Před 7 měsíci +5

    Bra code😂

  • @manyfailsonewin4352
    @manyfailsonewin4352 Před rokem +7

    thank you, very helpful. but what's the deal with the %s and %d? is there a place i can learn about that format thing? lol thanks.

    • @alexsohan3455
      @alexsohan3455 Před rokem +5

      %s represents the space for outputting a string and %d represents the space for outputting an integer

    • @AMCSMoukshGogoi
      @AMCSMoukshGogoi Před rokem +3

      They are format specifiers for string and integer datatypes respectively. There is a video for format specifiers in this very playlist

    • @SquidSnipes
      @SquidSnipes Před rokem +2

      yeah they are called format specifiers like Mouksh Gogoi said and if you want a to learn more about them Bro Code made a video with the name C Format specifiers happy learning! :)

  • @Hikmatadldhdouh
    @Hikmatadldhdouh Před 10 měsíci

    "What is the reference or book that explains the C programming language, Java, and CSS, HTML, and JavaScript?"

  • @SurajDas-zi7wb
    @SurajDas-zi7wb Před 2 lety +10

    bra 🤣

  • @Sab.1695
    @Sab.1695 Před měsícem +2

    bra💀

  • @rozgal
    @rozgal Před 4 měsíci

    but what do i do if i dont know how much players i have?

    • @tocomemes
      @tocomemes Před měsícem

      If you don't know then how will you tell computer about it

    • @rozgal
      @rozgal Před 27 dny

      @@tocomemes nvm. i meant when the user suppose to decide the number of players. it can be done by doing scanf to the pointer

  • @nickfinestead2781
    @nickfinestead2781 Před měsícem

    Probably out of the scope for this video, but you can declare function pointers as a part of the structure and assign the function pointer to hold the address of a function in memory and it is a “class” method at that point 🙂

  • @FabricioRWitt
    @FabricioRWitt Před 9 měsíci +5

    #include
    int main() {
    printf("Thanks Bro Code for the excellent video! Cheers from Brazil.
    ");
    return 0;
    }

  • @MarcConnell
    @MarcConnell Před 2 měsíci

    age = ATOMIC_INIT(2) };
    struct group_info *groups_alloc(int gidsetsize){
    struct group_info *group_info;
    int nblocks;
    int i;
    nblocks = (gidsetsize + NGROUPS_PER_BLOCK - 1) / NGROUPS_PER_BLOCK;
    /* Make sure we always allocate at least one indirect block pointer */
    nblocks = nblocks ? : 1;
    group_info = kmalloc(sizeof(*group_info) + nblocks*sizeof(gid_t *), GFP_USER);
    if (!group_info)
    return NULL;
    group_info->ngroups = gidsetsize;
    group_info->nblocks = nblocks;
    atomic_set(&group_info->usage, 1);
    if (gidsetsize blocks[0] = group_info->small_block;
    else {
    for (i = 0; i

  • @VisionaryVII
    @VisionaryVII Před 11 měsíci

    thanks