FranciscoSoccol

Lista 08 - Exercicio 11

Aug 10th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #define MAX 200
  4. //prototipo
  5. char* solicitaNome(void);
  6. //funçao main
  7. int main()
  8. {
  9.     int qtde,i;
  10.     printf("Digite a quantidade de nomes a ser lidos: ");
  11.     scanf("%d",&qtde);
  12.     char *aux[qtde];
  13.     for(i=0;i<qtde;i++)
  14.         aux[i]=solicitaNome();
  15.     for(i=0;i<qtde;i++)
  16.         printf("%s\n",aux[i]);
  17.     return 0;
  18. }
  19. //funçao solicita nomes
  20. char* solicitaNome(void)
  21. {
  22.     char nome[MAX],*aux;
  23.     printf("Digite um nome: ");
  24.     fflush(stdin);
  25.     gets(nome);
  26.     aux=(char*)malloc(sizeof(nome));//aux recebe o tamanha da palavra
  27.     strcpy(aux,nome);//aux recebe a palavra
  28. }
Advertisement
Add Comment
Please, Sign In to add comment