#include<stdio.h>
#include<stdlib.h>
typedef struct {
char *name;
char *phone;
char *city;
char *state;
} ficha_t;
void aloca(char **ptr, int tamanho) {
*ptr
= (char *)realloc(*ptr
, tamanho
+ 1); if(ptr == NULL){
puts("** Memória Insuficiente **"); }
}
char *preenche() {
char *dados = NULL;
int i = 0;
do {
aloca(&dados, i);
} while (dados[i - 1] != '\n');
dados[i - 1] = '\0';
return dados;
}
int main(int argc, const char *argv[]) {
ficha_t ficha;
ficha.name = preenche();
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RkbGliLmg+Cgp0eXBlZGVmIHN0cnVjdCB7CiAgICBjaGFyICpuYW1lOwogICAgY2hhciAqcGhvbmU7CiAgICBjaGFyICpjaXR5OwogICAgY2hhciAqc3RhdGU7Cn0gZmljaGFfdDsKCnZvaWQgYWxvY2EoY2hhciAqKnB0ciwgaW50IHRhbWFuaG8pIHsKICAgICpwdHIgPSAoY2hhciAqKXJlYWxsb2MoKnB0ciwgdGFtYW5obyArIDEpOwogICAgaWYocHRyID09IE5VTEwpewogICAgICAgIHB1dHMoIioqIE1lbcOzcmlhIEluc3VmaWNpZW50ZSAqKiIpOwogICAgICAgIGV4aXQoMCk7CiAgICB9Cn0KCmNoYXIgKnByZWVuY2hlKCkgewogICAgY2hhciAqZGFkb3MgPSBOVUxMOwogICAgaW50IGkgPSAwOwogICAgZG8gewogICAgICAgIGFsb2NhKCZkYWRvcywgaSk7CiAgICAgICAgZGFkb3NbaSsrXSA9IGdldGNoYXIoKTsKICAgIH0gd2hpbGUgKGRhZG9zW2kgLSAxXSAhPSAnXG4nKTsKICAgIGRhZG9zW2kgLSAxXSA9ICdcMCc7CiAgICByZXR1cm4gZGFkb3M7Cn0KCmludCBtYWluKGludCBhcmdjLCBjb25zdCBjaGFyICphcmd2W10pIHsKICAgIGZpY2hhX3QgZmljaGE7CiAgICBmaWNoYS5uYW1lID0gcHJlZW5jaGUoKTsKICAgIHByaW50ZigiJXMiLCBmaWNoYS5uYW1lKTsKICAgIHJldHVybiAwOwp9