Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- struct nomesL{
- char string[100];
- };
- int main(){
- int x,resp;
- int trava,cont;
- trava = trava + 1;
- do{
- printf("Por favor selecione uma opcao\n");
- printf("[1]Adicione mais um nome a lista\n");
- printf("[2]Encerrar o Programa\n");
- scanf("%d",&resp);
- switch (resp){
- case 1:
- x = x + 1;
- struct nomesL pessoas[x];
- int cont;
- char **str;
- str = malloc(x * sizeof(char*));
- for(cont = 0;cont < x;cont++){
- printf("Digite o nome\n");
- str[cont] = malloc(100);
- fgets(str[cont],100,stdin);
- system("cls");
- }
- for(cont = 0;cont < x;cont++){
- strcpy(pessoas[cont].string, &str[cont]);
- printf("%s\n",pessoas[cont].string);
- }
- break;
- }
- trava + 1;
- }while(trava);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement