C typedef 📛

preview_player
Показать описание
C typedef keyword tutorial example explained

#C #typedef #keyword

//typedef char user[25];

typedef struct
{
char name[25];
char password[12];
int id;
} User;

int main()
{
// typedef = reserved keyword that gives an existing datatype a "nickname"

User user1 = {"Bro", "password123", 123456789};
User user2 = {"Bruh", "password321", 987654321};

printf("\n");

return 0;
}
Рекомендации по теме
Комментарии
Автор

#include <stdio.h>
#include <string.h>

//typedef char user[25];

typedef struct
{
char name[25];
char password[12];
int id;
} User;

int main()
{
// typedef = reserved keyword that gives an existing datatype a "nickname"

User user1 = {"Bro", "password123", 123456789};
User user2 = {"Bruh", "password321", 987654321};

printf("%s\n", user1.name);
printf("%s\n", user1.password);
printf("%d\n", user1.id);
printf("\n");
printf("%s\n", user2.name);
printf("%s\n", user2.password);
printf("%d\n", user2.id);

return 0;
}

BroCodez
Автор

Just found this channel. Bro Code is the giga-chad of programming tutorials!

FastFSharp
Автор

to everyone here i advise you to code 1-2 examples to understand them fully it helped me alot

supeer
Автор

man at the end of the each tutorial when he says suscribe to become a fellow bro feels really good . a feeling of brotherhood (not gay )

theugliestking-wtby
Автор

Better than my Profs explanation, really appreciate the content.

Garrison
Автор

bro you dont understand how much you have helped me right now lmfao

woolyLinks
Автор

Seriously underranted videos. Well explained !

gdivya
Автор

Qht didn't you have to use strcpy() for the string in this one but we had to use that in the struct video?

jacquetrahan
Автор

Thank you so much you made C language so easy to understand

NoufM-lspv
Автор

ur videos always help me :)
Thank u very much <3

_txt_
Автор

nice and simple, do you have video explaining the arrow operator ?

offensivebias
Автор

I've seen structures declared differently by passing the struct name to malloc and returning a pointer...then the members are accessed like structname->member. what is the reason for this? I see this pattern a lot in C code, but don't know why it is done this way.

acatisfinetoo
Автор

So it basically just saves you from using the "struct" call to build a struct, doesn't really seem like too much of a time saver.

jeremyfonseca
Автор

why r u not getting views?
bcz of your short titles !

tushar
Автор

Hi im stupid. Why would this be prefered over using an array to hold the struct?

mangledskateboarding
Автор

Done! here's my code:

#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <ctype.h>

typedef struct{
char speciesName[40];
int legs;
bool endangered;
} animal;

int main(){
animal spider = {"Spider", 8, false}; // Or at least I assume spiders aren't endangered.
printf("The %s is ", spider.speciesName);
if(spider.endangered){
printf("an endangered species ");
}
else{
printf("a non endangered species ");
}
printf("that has %d legs.", spider.legs);

}

PSIwolf