Jump to content

[Resolvido] Problema com registos


badwolf

Recommended Posts

eu já andei a perder muito tempo com este pequeno código e não entendo o porque de não estar a trabalhar bem, sempre que executo o programa o programa só me deixa introduzir alguns dados e salta outros... se alguém me conseguir ajudar agradecia imenso, já não mexo com c com frequência e muitas vezes até os erros mais básicos faço... bem desde já agradeço a quem me ajudar

#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <string.h>
void inserir();
void menu ();
typedef struct zoo {
int numero_animal;
char nome;
char origem;
char local_cativeiro;
char data_entrada;
char tipo_alimentacao;
char especie;
int idade;
}Zoo;
using namespace std;
void menu(){

 int menuescolha;

printf("Menu\n");
printf("1 - Inserir Animal\n");
printf("2 - Pesquisar ficha do animal\n");
printf("3 - Listar animal ou animais\n");
printf("4 - Sair\n");

scanf("%d",&menuescolha);
switch (menuescolha){
case 1:
	 inserir();

break;
case 2:
 exit(EXIT_SUCCESS);
break;
case 3:
	 exit(EXIT_SUCCESS);
break;
case 4:
 exit(EXIT_SUCCESS);
break;

 }
}

void inserir(){
 Zoo novo[100];
 int num,idd,registo;
 char name,ori,local,data,alimentacao,esp;


 printf("INSERIR NOVO ANIMAL\n");

 printf("Por favor insira o numero do registo(1 a 100)\n\n");
 //caso o registo não seja auto-increment
 scanf("%d",&registo);
 //preenchimento da ficha em variaveis locais
 printf("Numero\n");
 scanf("%d",&num);
 printf("Nome\n");
 scanf("%c",&name);
 printf("Origem\n");
 scanf("%c",&ori);
 printf("Local de cativeiro\n");	
 scanf("%c",&local);
 printf("Data de entrada(dd|mm|aaaa)\n");
 scanf("%c",&data);
 printf("Tipo alimentacao\n");
 scanf("%c",&alimentacao);
 printf("Especie\n");
 scanf("%c",&esp);
 printf("Idade\n");
 scanf("%d",&idd);
 //transporte das variaveis locais para o registo
 novo[registo].numero_animal= num;
 novo[registo].nome =name ;
 novo[registo].origem =ori;
 novo[registo].local_cativeiro = local ;
 novo[registo].data_entrada = data;
 novo[registo].tipo_alimentacao = alimentacao;
 novo[registo].especie = esp;
 novo[registo].idade =idd;
 //voltar ao inicio do programa
 menu();

}
int main(int argc, char *argv[])
{
menu();


system("PAUSE");
return EXIT_SUCCESS;
}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.