Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<malloc.h>
- #include<string.h>
- typedef struct redeSocial{
- char N[15];
- int T;
- int A;
- char *LA;
- }RS;
- int main(){
- RS *p;
- int qnt;
- printf("Digite quantos sao os usuarios: ");
- scanf("%d", &qnt);
- p=(RS*)malloc(sizeof(RS)*qnt);
- for(int i=0;i<qnt;i++)
- {
- setbuf(stdin, NULL);
- printf("Digite o nome do %d usuario: ", i+1);
- fgets((p+i)->N, 15, stdin);
- setbuf(stdin, NULL);
- (p+i)->T=strlen((p+i)->N);
- printf("Quantos amigos ele tem?\n");
- scanf("%d", &((p+i)->A));
- setbuf(stdin, NULL);
- (p+i)->LA=(char*)malloc(sizeof(char)*((p+i)->A));
- for(int j=0; j<((p+i)->A);j++){
- printf("Qual o nome do %d amigo?\n", j+1);
- fgets((p+i)->LA+j, 15, stdin);
- setbuf(stdin, NULL);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement