Тёмный

C structs 🏠 

Bro Code
Подписаться 2,2 млн
Просмотров 200 тыс.
50% 1

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

Опубликовано:

 

1 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 54   
@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 :)
@johnc3403
@johnc3403 Год назад
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
@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.
@NezarAhmed57
@NezarAhmed57 8 месяцев назад
2:46 bra! what a coole name lmao thank you bro for the lesson, we appreciate your work
@naveenkumar1853
@naveenkumar1853 10 месяцев назад
Bra code😂
@GuedriaRayen
@GuedriaRayen 11 месяцев назад
poor player2, he didn't deserve such a name 😥
@14k46
@14k46 2 месяца назад
lol
@wacky_aman
@wacky_aman Год назад
omg i understood it in first try hehe, thank you bra XD
@SurajDas-zi7wb
@SurajDas-zi7wb 2 года назад
bra 🤣
@spicasuzuki1908
@spicasuzuki1908 2 года назад
bracode
@weldejewergskahsay
@weldejewergskahsay 7 месяцев назад
that is nice presentation but please help us in structure and function related codes.thanks
@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! :)
@Garrison86
@Garrison86 2 года назад
Amazing!! thanks for the clear explanation.
@Sab.1695
@Sab.1695 4 месяца назад
bra💀
@possiblyzslot838
@possiblyzslot838 Год назад
Lifesaver.
@pattyspanker8955
@pattyspanker8955 Год назад
Yes, happy to see BroCode has a video on this
@FabricioRWitt
@FabricioRWitt 11 месяцев назад
#include int main() { printf("Thanks Bro Code for the excellent video! Cheers from Brazil. "); return 0; }
@musa8693
@musa8693 16 дней назад
Why is it that we do struct when we can just do the normally can’t we?
@jadedrakerider
@jadedrakerider Месяц назад
THANK YOU!!! Why is this so hard to explain? Thank you so much I finally understand.
@ForeverNils
@ForeverNils 2 месяца назад
what about ABI and aligning structs between different architectures?
@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
@techplayz06
@techplayz06 3 месяца назад
Very clear explanation! Thank you!
@Hikmatadldhdouh
@Hikmatadldhdouh Год назад
"What is the reference or book that explains the C programming language, Java, and CSS, HTML, and JavaScript?"
@SushiK994
@SushiK994 3 года назад
Yo bro make a video on pointers plz
@billyboone69
@billyboone69 2 года назад
Thanks Bro
@fo3musaib888
@fo3musaib888 Год назад
great info
@VisionaryVII
@VisionaryVII Год назад
thanks
@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
@dumbcat720
@dumbcat720 Год назад
thanks bro meow
@denifer_
@denifer_ 5 месяцев назад
W
@creepydog3903
@creepydog3903 11 месяцев назад
thank you
@ashvikvijai8114
@ashvikvijai8114 5 месяцев назад
fire vid
@AnnaProvidenceAloyem
@AnnaProvidenceAloyem 11 месяцев назад
Nice
@alpiinoo135
@alpiinoo135 11 месяцев назад
Thanks!
@sunstixy
@sunstixy 11 месяцев назад
Nice lesson, thanks ^^
@r00tgod
@r00tgod 3 года назад
ty
@yusraazrademirel2195
@yusraazrademirel2195 Год назад
thanks
@nick2781-r1n
@nick2781-r1n 3 месяца назад
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.
@simonG-R.
@simonG-R. Год назад
Thanks! it helped a lot.
@bikdigdaddy
@bikdigdaddy Год назад
perfect, its concize.
Далее
C typedef 📛
3:33
Просмотров 69 тыс.
#kikakim
00:10
Просмотров 11 млн
struct Basics | C Programming Tutorial
24:44
Просмотров 140 тыс.
how Google writes gorgeous C++
7:40
Просмотров 891 тыс.
Learn Linked Lists in 13 minutes 🔗
13:24
Просмотров 306 тыс.
why do header files even exist?
10:53
Просмотров 410 тыс.
"Clean" Code, Horrible Performance
22:41
Просмотров 891 тыс.
C pointers explained👉
8:04
Просмотров 170 тыс.