Lgub
Super Participante
Registrado
936 Mensagens
1 Curtida
Tem que ser em C++??? Pq se for em C, posso te ajudar.
Tenho aqui num livro.
Linux User:#326216
Intel I7 - 920 - 6G DDR3 Tripple Channel @1600 - Geforce 285 1G.
Programador ADVPL(Fazer o que é o que ta pagando as contas no momento...)
Tung
Membro Senior
Registrado
305 Mensagens
0 Curtidas
To viajando.... eh em C e naum em C++
Lgub
Super Participante
Registrado
936 Mensagens
1 Curtida
Vou postar aqui, daki a pouco...
Perai
Linux User:#326216
Intel I7 - 920 - 6G DDR3 Tripple Channel @1600 - Geforce 285 1G.
Programador ADVPL(Fazer o que é o que ta pagando as contas no momento...)
Lgub
Super Participante
Registrado
936 Mensagens
1 Curtida
aqui vai:
O Exemplo esta bem simples, o ideal seria usar uma lista linkada, mas ve se isso te ajuda..
Falou
#include
#include
void lista();
void novonome();
struct lista{
char titulo[30];
char autor[30];
int regnum;
double preco;
};
struct lista livro[50];
int n=0;
int main()
{
char ch;
while(1){
printf("Digite ´e´ para adicionar\nDigte ´l´ para listar:");
ch=getche();
switch (ch)
{
case 'e' :novonome();break;
case 'l' :lista();break;
}
}
}
/* novo nome()*/
void novonome(){
char numstr[81];
printf("\nRegistro %d. \n Digite o titulo: ",n+1);
gets(livro[n].titulo);
printf("\nDigite o autor:");
gets(livros[n].autor);
printf("\nDigite o nº do livro(3 digitos):");
gets(numstr);
livro[n].regnum=atoi(numstr); // Atoi converte string em nº inteiro
printf("Digite preço:");
gets(numstr);
livro[n].preco=atof(numstr); // Atof converte string em nº float
n++;
}
void lista()
{
int i;
if (!n)
printf("\nLista Vazia.");
else
for(i=0;i
printf("\nRegistro:%d\n\nTitulo:%s\n\nAutor:%s\n\nNº de registro: %3d.",i+1,livro[i].titulo,livro[i].autor,livro[i].regnum);
printf(\nPreço:%4.2f . \n",livro[i].preco);
}
}
Linux User:#326216
Intel I7 - 920 - 6G DDR3 Tripple Channel @1600 - Geforce 285 1G.
Programador ADVPL(Fazer o que é o que ta pagando as contas no momento...)
Tung
Membro Senior
Registrado
305 Mensagens
0 Curtidas
serve sim valeu mesmo.