Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #define MAX 200
- //prototipo
- char* solicitaNome(void);
- //funçao main
- int main()
- {
- int qtde,i;
- printf("Digite a quantidade de nomes a ser lidos: ");
- scanf("%d",&qtde);
- char *aux[qtde];
- for(i=0;i<qtde;i++)
- aux[i]=solicitaNome();
- for(i=0;i<qtde;i++)
- printf("%s\n",aux[i]);
- return 0;
- }
- //funçao solicita nomes
- char* solicitaNome(void)
- {
- char nome[MAX],*aux;
- printf("Digite um nome: ");
- fflush(stdin);
- gets(nome);
- aux=(char*)malloc(sizeof(nome));//aux recebe o tamanha da palavra
- strcpy(aux,nome);//aux recebe a palavra
- }
Advertisement
Add Comment
Please, Sign In to add comment