#include <stdio.h>
#include <stdlib.h>
typedef struct {
char * nome;
char * numero;
} Agenda;
void adiciona( Agenda* reg, int i) {
scanf ( "%s" , reg
[ i
] .
nome ) ; scanf ( "%s" , reg
[ i
] .
numero ) ; }
void imprime( Agenda* reg, int i) {
for ( int j = 0 ; j < i; j++ ) {
printf ( "Nome: %s | " , reg
[ j
] .
nome ) ; printf ( "Numero: %s\n " , reg
[ j
] .
numero ) ; }
}
int main( ) {
int sair = 0 ;
int i = 0 ;
Agenda registro[ 10 ] ;
while ( ! sair) {
int escolha;
printf ( "O que voce deseja ? (1)Inserir (2)Imprimir (3)Sair\n " ) ; switch ( escolha) {
case 1 :
adiciona( registro, i) ;
i++;
break ;
case 2 :
imprime( registro, i) ;
break ;
case 3 :
sair = 1 ;
break ;
}
}
}
//https://pt.stackoverflow.com/q/209878/101
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCnR5cGVkZWYgc3RydWN0IHsKICAgIGNoYXIgKm5vbWU7CiAgICBjaGFyICpudW1lcm87Cgp9IEFnZW5kYTsKCnZvaWQgYWRpY2lvbmEoQWdlbmRhKiByZWcsIGludCBpKSB7CiAgICByZWdbaV0ubm9tZSA9IG1hbGxvYygzMCk7CiAgICByZWdbaV0ubnVtZXJvID0gbWFsbG9jKDYpOwogICAgc2NhbmYoIiVzIiwgcmVnW2ldLm5vbWUpOwogICAgc2NhbmYoIiVzIiwgcmVnW2ldLm51bWVybyk7Cn0KCnZvaWQgaW1wcmltZShBZ2VuZGEqIHJlZywgaW50IGkpIHsKICAgIGZvciAoaW50IGogPSAwOyBqIDwgaTsgaisrKSB7CiAgICAgICAgcHJpbnRmKCJOb21lOiAlcyB8ICIsIHJlZ1tqXS5ub21lKTsKICAgICAgICBwcmludGYoIk51bWVybzogJXNcbiIsIHJlZ1tqXS5udW1lcm8pOwogICAgfQp9CgppbnQgbWFpbigpIHsKICAgIGludCBzYWlyID0gMDsKICAgIGludCBpID0gMDsKICAgIEFnZW5kYSByZWdpc3Ryb1sxMF07CiAgICB3aGlsZSAoIXNhaXIpIHsKICAgICAgICBpbnQgZXNjb2xoYTsKICAgICAgICBwcmludGYoIk8gcXVlIHZvY2UgZGVzZWphID8gKDEpSW5zZXJpciAoMilJbXByaW1pciAoMylTYWlyXG4iKTsKICAgICAgICBzY2FuZigiJWQiLCAmZXNjb2xoYSk7CiAgICAgICAgc3dpdGNoKGVzY29saGEpIHsgICAgICAgCiAgICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgICAgIGFkaWNpb25hKHJlZ2lzdHJvLCBpKTsKICAgICAgICAgICAgICAgIGkrKzsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDI6CiAgICAgICAgICAgICAgICBpbXByaW1lKHJlZ2lzdHJvLCBpKTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgICAgICBzYWlyID0gMTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0gCiAgICB9Cn0KCi8vaHR0cHM6Ly9wdC5zdGFja292ZXJmbG93LmNvbS9xLzIwOTg3OC8xMDE=