C structs 🏠

  Рет қаралды 203,173

Bro Code

Bro Code

Күн бұрын

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;
}

Пікірлер: 55
@BroCodez
@BroCodez 3 жыл бұрын
#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; }
@Angel-Pizzaeater
@Angel-Pizzaeater 2 жыл бұрын
hi bro code
@sunstixy
@sunstixy 11 ай бұрын
Very good :)
@hand-eye4517
@hand-eye4517 2 жыл бұрын
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 2 жыл бұрын
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.
@hihwsjai188
@hihwsjai188 Жыл бұрын
'over the shoulder boulder holder' XD
@yashhhh740
@yashhhh740 Жыл бұрын
lmao, xD
@danish_parve
@danish_parve Жыл бұрын
😂😂
@creedbratton4950
@creedbratton4950 4 ай бұрын
XD XD
@NezarAhmed57
@NezarAhmed57 8 ай бұрын
2:46 bra! what a coole name lmao thank you bro for the lesson, we appreciate your work
@pattyspanker8955
@pattyspanker8955 Жыл бұрын
Yes, happy to see BroCode has a video on this
@weldejewergskahsay
@weldejewergskahsay 7 ай бұрын
that is nice presentation but please help us in structure and function related codes.thanks
@saviofialho143
@saviofialho143 Күн бұрын
Excelent! Great video.
@Garrison86
@Garrison86 2 жыл бұрын
Amazing!! thanks for the clear explanation.
@jadedrakerider
@jadedrakerider Ай бұрын
THANK YOU!!! Why is this so hard to explain? Thank you so much I finally understand.
@wacky_aman
@wacky_aman Жыл бұрын
omg i understood it in first try hehe, thank you bra XD
@GuedriaRayen
@GuedriaRayen 11 ай бұрын
poor player2, he didn't deserve such a name 😥
@14k46
@14k46 2 ай бұрын
lol
@possiblyzslot838
@possiblyzslot838 Жыл бұрын
Lifesaver.
@techplayz06
@techplayz06 3 ай бұрын
Very clear explanation! Thank you!
@manyfailsonewin4352
@manyfailsonewin4352 2 жыл бұрын
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 Жыл бұрын
%s represents the space for outputting a string and %d represents the space for outputting an integer
@MoukshGogoi
@MoukshGogoi Жыл бұрын
They are format specifiers for string and integer datatypes respectively. There is a video for format specifiers in this very playlist
@SquidSnipes
@SquidSnipes Жыл бұрын
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! :)
@fo3musaib888
@fo3musaib888 Жыл бұрын
great info
@ForeverNils
@ForeverNils 2 ай бұрын
what about ABI and aligning structs between different architectures?
@sunstixy
@sunstixy 11 ай бұрын
Nice lesson, thanks ^^
@creepydog3903
@creepydog3903 Жыл бұрын
thank you
@alpiinoo135
@alpiinoo135 11 ай бұрын
Thanks!
@VisionaryVII
@VisionaryVII Жыл бұрын
thanks
@simonG-R.
@simonG-R. Жыл бұрын
Thanks! it helped a lot.
@SushiK994
@SushiK994 3 жыл бұрын
Yo bro make a video on pointers plz
@billyboone69
@billyboone69 2 жыл бұрын
Thanks Bro
@AnnaProvidenceAloyem
@AnnaProvidenceAloyem 11 ай бұрын
Nice
@nick2781-r1n
@nick2781-r1n 4 ай бұрын
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 🙂
@effsixteenblock50
@effsixteenblock50 Ай бұрын
Exactly what I was thinking.
@ashvikvijai8114
@ashvikvijai8114 5 ай бұрын
fire vid
@musa8693
@musa8693 24 күн бұрын
Why is it that we do struct when we can just do the normally can’t we?
@Hikmatadldhdouh
@Hikmatadldhdouh Жыл бұрын
"What is the reference or book that explains the C programming language, Java, and CSS, HTML, and JavaScript?"
@r00tgod
@r00tgod 3 жыл бұрын
ty
@dumbcat720
@dumbcat720 Жыл бұрын
thanks bro meow
@denifer_
@denifer_ 5 ай бұрын
W
@rozgal
@rozgal 7 ай бұрын
but what do i do if i dont know how much players i have?
@tocomemes
@tocomemes 4 ай бұрын
If you don't know then how will you tell computer about it
@rozgal
@rozgal 3 ай бұрын
@@tocomemes nvm. i meant when the user suppose to decide the number of players. it can be done by doing scanf to the pointer
@Cinarbayramic
@Cinarbayramic 2 ай бұрын
Initialise the players in an array then use sizeof() to get the players amount
@naveenkumar1853
@naveenkumar1853 10 ай бұрын
Bra code😂
@SurajDas-zi7wb
@SurajDas-zi7wb 3 жыл бұрын
bra 🤣
@spicasuzuki1908
@spicasuzuki1908 2 жыл бұрын
bracode
@Sab.1695
@Sab.1695 4 ай бұрын
bra💀
@FabricioRWitt
@FabricioRWitt Жыл бұрын
#include int main() { printf("Thanks Bro Code for the excellent video! Cheers from Brazil. "); return 0; }
@bikdigdaddy
@bikdigdaddy Жыл бұрын
perfect, its concize.
@MarcConnell
@MarcConnell 5 ай бұрын
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
@yusraazrademirel2195
@yusraazrademirel2195 Жыл бұрын
thanks
C typedef 📛
3:33
Bro Code
Рет қаралды 70 М.
struct Basics | C Programming Tutorial
24:44
Portfolio Courses
Рет қаралды 141 М.
1 сквиш тебе или 2 другому? 😌 #шортс #виола
00:36
Inside Out 2: ENVY & DISGUST STOLE JOY's DRINKS!!
00:32
AnythingAlexia
Рет қаралды 17 МЛН
哈哈大家为了进去也是想尽办法!#火影忍者 #佐助 #家庭
00:33
火影忍者一家
Рет қаралды 111 МЛН
CLASSES vs STRUCTS in C++
8:32
The Cherno
Рет қаралды 470 М.
you will never ask about pointers again after watching this video
8:03
Learn Linked Lists in 13 minutes 🔗
13:24
Bro Code
Рет қаралды 312 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 795 М.
why do header files even exist?
10:53
Low Level
Рет қаралды 413 М.
What are Value Types and Reference Types in C#? (Class vs Struct)
10:55
#26  C Struct | C Programming for Beginners
13:37
Programiz
Рет қаралды 82 М.
The Flaws of Inheritance
10:01
CodeAesthetic
Рет қаралды 951 М.
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 313 М.
C pointers explained👉
8:04
Bro Code
Рет қаралды 174 М.
1 сквиш тебе или 2 другому? 😌 #шортс #виола
00:36