This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct { | |
char nome[50]; | |
int ra; | |
char curso[30]; | |
char polo[50]; | |
int bimestre; | |
double aprov; | |
} Aluno; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct { | |
<tipo> <nome_da_variável>; | |
... // outras variáveis | |
} <Nome_da_estrutura>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Aluno maria; | |
maria.curso = "Computação"; | |
maria.nome = "Maria Conceição"; | |
maria.ra = 1700933; | |
maria.aprov = 9.2; | |
maria.polo = "Ilha Bela"; | |
maria.bimestre = 9; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Aluno maria = { | |
"Maria Conceição", | |
1700933, | |
"Computação", | |
"Ilha Bela", | |
9, | |
9.3 | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// para visualizar | |
printf ( "Curso: %s\n", maria.curso ); | |
// para atualizar | |
maria.polo = "Osasco"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usando typedef | |
Aluno joao = { ... }; | |
// sem usar typedef | |
struct Aluno maria = { ... }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usando operador ponto | |
maria.ra = 001234567; | |
// usando operador seta | |
joao->ra = 007654321; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// declaramos uma estrutura "joao" de tipo Aluno | |
// e acessamos diretamente com o operador ponto | |
Aluno joao; | |
joao.nome = "João"; | |
// declaramos um ponteiro a uma estrutura e | |
// acessamos indiretamente com o operador seta | |
Aluno *ptr_joao = &joao; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usando o operador seta | |
ptr->membro = valor; | |
// usando a forma tradicional | |
(*ptr).membro = valor; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int num[] = {1, 5, 9 ,0, 4, 3}; | |
// aqui o índice 2 é usado para identificar | |
// o terceiro elemento do array | |
num[2] = -7; |
OlderNewer