fork download
  1. #include <string.h>
  2. #include <stdio.h>
  3.  
  4. typedef struct {
  5. char nome[81];
  6. char ano[5];
  7. char diretor[81];
  8. } Filme;
  9.  
  10. void analise(Filme *filme, const char *arg1, const char *arg2, const char *arg3) {
  11. strcpy(filme->nome, arg1);
  12. strcpy(filme->ano, arg2);
  13. strcpy(filme->diretor, arg3);
  14. }
  15.  
  16. void carregar(Filme filmes[]) {
  17. analise(&filmes[0], "E o Vento Levou", "1939", "Victor");
  18. analise(&filmes[1], "teste", "998", "bar");
  19. analise(&filmes[2], "Os Passaros", "1963", "Alfred Hitchcock");
  20. }
  21.  
  22. int main() {
  23. Filme filmes[1000];
  24. carregar(filmes);
  25. printf("\nmain:\n");
  26. for (int i = 0; i < 3; i++) {
  27. printf("- Nome: %s\n", filmes[i].nome);
  28. printf("- Ano: %s\n", filmes[i].ano);
  29. printf("- Diretor: %s\n", filmes[i].diretor);
  30. printf("----------------\n");
  31. }
  32. }
  33.  
  34. //https://pt.stackoverflow.com/q/303948/101
Success #stdin #stdout 0s 4600KB
stdin
Standard input is empty
stdout
main:
- Nome:    E o Vento Levou
- Ano:     1939
- Diretor: Victor
----------------
- Nome:    teste
- Ano:     998
- Diretor: bar
----------------
- Nome:    Os Passaros
- Ano:     1963
- Diretor: Alfred Hitchcock
----------------