Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define MAX 100
- #define MAX_TAM_NOME 50
- char* solicitaNome(void);
- int main() {
- int qtde, i;
- char* vet[MAX];
- printf("Quants nomes? ");
- scanf("%d",&qtde);
- for(i=0; i<qtde; i++) {
- vet[i] = solicitaNome();
- }
- printf("\nNomes:\n");
- for(i=0; i<qtde; i++) {
- printf("%s \n",vet[i]);
- }
- return 0;
- }
- char* solicitaNome(void) {
- char *nome;
- char aux[MAX_TAM_NOME];
- printf("Entre com o nome: ");
- fflush(stdin);
- gets(aux);
- nome = (char*)malloc(strlen(aux)+1);
- strcpy(nome,aux);
- return nome;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement