pr0zin Posted April 25, 2012 at 04:00 PM Report #451392 Posted April 25, 2012 at 04:00 PM Boa tarde amigos, estou aqui com 1 duvida no meu programa, quando executo ele nao me mostra a informaçao, nao sei se o problema esta no modo como leio os dados ou como mostro, sera que alguem me pode dar uma olhadela e dizer me o que esta mal? Obrigado =D #include<stdio.h> typedef struct num_serv_sec { int num_serie; }NSS; typedef struct info_pessoal { char nome[100]; int dia_nasc; int mes_nasc; int ano_nasc; int altura; char olhos[100]; char cabelo[100]; }info_ppl; typedef struct info_numer { int bi; int contribuinte; int seg_social; int carta_cond; }inf_numeros; typedef struct morada { char rua[100]; int cod_postal1; int cod_postal2; char cod_postal3[100]; }morada; typedef struct confid { char partido[100]; char clube[100]; }confidencial; int le_nss(NSS *ptr) { printf("Qual e' o numero de serie do cidadao ? :"); scanf("%d", &(*ptr).num_serie); } void le_info_pessoal(info_ppl *ptr) { printf("\nIntroduz o Nome: "); scanf(" %s", (*ptr).nome); printf("\nDia de Nascimento(1 a 31): "); scanf(" %d", &(*ptr).dia_nasc); printf("\nMes(1 a 12): "); scanf(" %d", &(*ptr).mes_nasc); printf("\nAno(1 a 2012): "); scanf(" %d", &(*ptr).ano_nasc); printf("\nAltura(cm): "); scanf(" %d", &(*ptr).altura); printf("\nCor dos Olhos: "); scanf(" %s", (*ptr).olhos); printf("\nCor do Cabelo: "); scanf(" %s", (*ptr).cabelo); } int le_info_numer(inf_numeros *ptr) { printf("Introduz o Numero do\nBI: "); scanf(" %d", &(*ptr).bi); printf("\nContribuinte: "); scanf(" %d", &(*ptr).contribuinte); printf("\nSeguranca Social: "); scanf(" %d", &(*ptr).seg_social); printf("\nCarta de Conduçao: "); scanf(" %d", &(*ptr).carta_cond); } void le_morada(morada *ptr) { printf("Qual e' a tua rua? Insere - em vez de space, (por exemplo Rua-das-Flores)\n"); scanf(" %s", (*ptr).rua); printf("Qual e' o teu codigo postal? ex 4500 - 766: "); scanf("%d - %d", &(*ptr).cod_postal1, &(*ptr).cod_postal2); printf("\nQual e' a tua localidade? :"); scanf(" %s", (*ptr).cod_postal3); } void le_confidencial(confidencial *ptr) { printf("\nQual e' o partido? :"); scanf(" %s", (*ptr).partido); printf("\nQual e' o clube? :"); scanf(" %s",(*ptr).clube); } typedef struct cidadao { struct num_serv_sec NSS; struct info_pessoal info_ppl; struct info_numer inf_numeros; struct morada morada; struct confid confidencial; }cidadao; void funcao_cidadao(cidadao *ptr) { le_nss(&ptr); le_info_pessoal(&ptr); le_info_numer(&ptr); le_morada(&ptr); le_confidencial(&ptr); } void mostrar_dados(cidadao *ptr) { printf("NSS: \t%d\n\n", ptr->NSS.num_serie); printf("Nome: \t%s\n", ptr->info_ppl.nome); printf("Nasceu a \t%d / %d / %d\n", ptr->info_ppl.dia_nasc, ptr->info_ppl.mes_nasc, ptr->info_ppl.dia_nasc); printf("Altura: \t%d cm\n", ptr->info_ppl.altura); printf("Cor dos Olhos: \t%s\n", ptr->info_ppl.olhos); printf("Cor do cabelo: \t%s\n\n", ptr->info_ppl.cabelo); printf("BI: \t%d\n", ptr->inf_numeros.bi); printf("Contribuinte: \t%d\n", ptr->inf_numeros.contribuinte); printf("Seguranca Social: \t%d\n", ptr->inf_numeros.seg_social); printf("Carta de Conducao: \t%d\n\n", ptr->inf_numeros.carta_cond); printf("Mora em %s %d - %d , %s\n", ptr->morada.rua, ptr->morada.cod_postal1, ptr->morada.cod_postal2, ptr->morada.cod_postal3); printf("Partido: \t%s\n", ptr->confidencial.partido); printf("Clube: \t%s\n", ptr->confidencial.clube); } main() { struct morada um; funcao_cidadao(&um); mostrar_dados(&um); }
HappyHippyHippo Posted April 25, 2012 at 04:16 PM Report #451396 Posted April 25, 2012 at 04:16 PM 1º - dá algum tipo de warning na compilação 2º - que tipo de informação aparece/não aparece 3º - o que deveria aparecer/não aparecer .... aqui ninguém trabalha no oráculo de Apolo ... IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
pmg Posted April 25, 2012 at 04:26 PM Report #451402 Posted April 25, 2012 at 04:26 PM Sugestao: aumenta o nivel de warnings do teu compilador e faz compilacoes limpas. $ gcc 65378.c 65378.c: In function ‘funcao_cidadao’: 65378.c:116:9: warning: passing argument 1 of ‘le_nss’ from incompatible pointer type [enabled by default] 65378.c:45:5: note: expected ‘struct NSS *’ but argument is of type ‘struct cidadao **’ 65378.c:117:9: warning: passing argument 1 of ‘le_info_pessoal’ from incompatible pointer type [enabled by default] 65378.c:52:6: note: expected ‘struct info_ppl *’ but argument is of type ‘struct cidadao **’ 65378.c:118:9: warning: passing argument 1 of ‘le_info_numer’ from incompatible pointer type [enabled by default] 65378.c:71:5: note: expected ‘struct inf_numeros *’ but argument is of type ‘struct cidadao **’ 65378.c:119:9: warning: passing argument 1 of ‘le_morada’ from incompatible pointer type [enabled by default] 65378.c:83:6: note: expected ‘struct morada *’ but argument is of type ‘struct cidadao **’ 65378.c:120:9: warning: passing argument 1 of ‘le_confidencial’ from incompatible pointer type [enabled by default] 65378.c:94:6: note: expected ‘struct confidencial *’ but argument is of type ‘struct cidadao **’ 65378.c: In function ‘main’: 65378.c:146:9: warning: passing argument 1 of ‘funcao_cidadao’ from incompatible pointer type [enabled by default] 65378.c:113:6: note: expected ‘struct cidadao *’ but argument is of type ‘struct morada *’ 65378.c:147:9: warning: passing argument 1 of ‘mostrar_dados’ from incompatible pointer type [enabled by default] 65378.c:127:6: note: expected ‘struct cidadao *’ but argument is of type ‘struct morada *’ What have you tried? Não respondo a dúvidas por PM A minha bola de cristal está para compor; deve ficar pronta para a semana. Torna os teus tópicos mais atractivos e legíveis usando a tag CODE para colorir o código!
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