Enviado em 18/06/2018 - 21:28h
#include <stdio.h> #include <string.h> enum Gender{male, female, gay, flowing_gender}; struct __person{ char complete_name[256]; char cpf[12], rg[10]; Gender gender; }person; int main(void){ strncat(person.complete_name, "Cleinivaldo Sakrudi", 256); strncat(person.cpf, "82834635005", 12); strncat(person.rg, "412125304", 10); person.gender=flowing_gender; return 0; }
Enviado em 19/06/2018 - 16:00h
Acrescentando à resposta anterior:enum Gender{male, female, gay, flowing_gender}; struct __person{ char complete_name[256]; char cpf[12], rg[10]; enum Gender gender; }person;
6.7 Declarations declaration: declaration-specifiers init-declarator-listopt ; static_assert-declaration declaration-specifiers: storage-class-specifier declaration-specifiersopt type-specifier declaration-specifiersopt type-qualifier declaration-specifiersopt function-specifier declaration-specifiersopt alignment-specifier declaration-specifiersopt init-declarator-list: init-declarator init-declarator-list , init-declarator init-declarator: declarator declarator = initializer
6.7.2 - Type specifiers type-specifer: void char short int long float double signed unsigned unsigned _Bool _Complex atomic-type-specifier struct-or-union-specifier enum-specifier typedef-name
enum-specifier: enum identifieropt { enumerator-list } enum identifieropt { enumerator-list , } enum identifier
$ indent -kr -i8 src.c "(...)all right-thinking people know that (a) K&R are _right_ and (b) K&R are right." - linux/Documentation/CodingStyle - TORVALDS, Linus.
Enviado em 19/06/2018 - 09:30h
Opa!#include <stdio.h> #include <string.h> typedef enum {male, female, gay, flowing_gender} Gender; struct __person{ char complete_name[256]; char cpf[12], rg[10]; Gender gender; } person; int main(void){ strncat(person.complete_name, "Cleinivaldo Sakrudi", 256); strncat(person.cpf, "82834635005", 12); strncat(person.rg, "412125304", 10); person.gender=flowing_gender; return 0; }
Enviado em 19/06/2018 - 18:49h
#include <stdio.h> #include <string.h> typedef enum {male, female, gay, flowing_gender} Gender; struct __person{ char complete_name[256]; char cpf[12], rg[10]; Gender gender; } person; int main(void){ strncat(person.complete_name, "Cleinivaldo Sakrudi", 256); strncat(person.cpf, "82834635005", 12); strncat(person.rg, "412125304", 10); person.gender=flowing_gender; return 0; }
typedef enum __Gender{male, female, gay, flowing_gender}Gender;
typedef enum {male, female, gay, flowing_gender}Gender;
typedef struct{ double __fock_my_life; char mongoood[42]; }My_struct;
typedef struct __My_struct{ double __fock_my_life; char mongoood[42]; }My_struct;
Enviado em 19/06/2018 - 19:07h
typedef enum { ... } Gender; // (1) typedef enum __Gender { ... } Gender; // (2)
typedef struct { int info; Node *next; Node *prev; } Node;
typedef struct __node { int info; struct __node *next; struct __node *prev; } Node;
typedef struct __node Node; struct __node { int info; Node *next; Node *prev; };
$ indent -kr -i8 src.c "(...)all right-thinking people know that (a) K&R are _right_ and (b) K&R are right." - linux/Documentation/CodingStyle - TORVALDS, Linus.
Enviado em 19/06/2018 - 19:47h
typedef enum { ... } Gender; // (1) typedef enum __Gender { ... } Gender; // (2)
Enviado em 19/06/2018 - 20:43h
$ indent -kr -i8 src.c "(...)all right-thinking people know that (a) K&R are _right_ and (b) K&R are right." - linux/Documentation/CodingStyle - TORVALDS, Linus.
Enviado em 19/06/2018 - 22:51h
Como dito anteriormente, eu sou bastante curioso. Apesar de saber como funciona (bem superficialmente), estou dando uma lida no C11 pra explicar melhor.// caso 1 - estrutura definida pelo identificador `ident`, cria um novo tipo `struct ident` struct ident { int foo, bar; }; // caso 2 - estrutura anônima struct { int a, b, c; };
typedef struct { int a, b, c; } MyStruct;
typedef [tipo] [alias_name]
$ indent -kr -i8 src.c "(...)all right-thinking people know that (a) K&R are _right_ and (b) K&R are right." - linux/Documentation/CodingStyle - TORVALDS, Linus.
tux-gpt - Assistente de IA para o Terminal
Instalação e configuração do Chrony
Programa IRPF - Guia de Instalação e Resolução de alguns Problemas
Como instalar no Linux Jogos da Steam só para Windows
Instalando o Team Viewer no Debian Trixie - problema no Policykit
O Que Fazer Após Instalar Ubuntu 25.04
Graduação e certificação Eng. de redes e Eng. Linux[DUVIDA] (0)
Controle do PS5 no Linux Mint funciona? (3)
Autenticação necessária. um aplicativo quer acesso ao chaveiro "c... (1)