#include "stdio.h" #include "string.h" void ex01() { FILE *f; f = fopen("Source.cpp", "r"); int l=0, c=0; char v[500]; while (!feof(f)) { fgets(v,500,f); l++; c += strlen(v); printf("[%3d] %s", l, v); } printf("%d\n%d\n", l, c); fclose(f); } typedef struct { char email[100]; char pass[100]; } conta; typedef struct { conta dados[10]; int base, topo, tamanho; } pilha; void inicializaPilha(pilha *pont_p) { pont_p->base = pont_p->topo = 0; pont_p->tamanho = 0; } void empilha(pilha *pont_p, conta dados) { if (pont_p->tamanho == 10) { printf("Sorry, I can't\n"); return ; } strcpy(pont_p->dados[pont_p->topo].email, dados.email); strcpy(pont_p->dados[pont_p->topo].pass, dados.pass); pont_p->topo++; pont_p->tamanho++; } void desempilha(pilha *pont_p) { if (pont_p->base == pont_p->topo) { printf("Sorry, I can't\n"); return ; } pont_p->topo--; pont_p->tamanho--; printf("[%2d] User: %s Pass: %s\n", pont_p->tamanho, pont_p->dados[pont_p->tamanho].email, pont_p->dados[pont_p->tamanho].pass); } int main() { pilha p; inicializaPilha(&p); conta c1; strcpy(c1.email, "teste@teste.com.br"); strcpy(c1.pass, "teste"); for (int i = 0; i < 13; i++) empilha(&p, c1); for (int i = 0; i < 13; i++) desempilha(&p); return 0; }