badwolf Posted June 18, 2012 at 10:49 PM Report Share #463880 Posted June 18, 2012 at 10:49 PM 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",®isto); //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 More sharing options...
HappyHippyHippo Posted June 18, 2012 at 10:53 PM Report Share #463881 Posted June 18, 2012 at 10:53 PM (edited) faz limpeza do buffer de leitura após (ou durante) qualquer leitura do teclado Edited June 18, 2012 at 10:53 PM by HappyHippyHippo IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
badwolf Posted June 18, 2012 at 11:26 PM Author Report Share #463885 Posted June 18, 2012 at 11:26 PM ty para já parece que resolveu o meu problema 🙂 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now