joaovilaca94 Posted July 14, 2014 at 02:54 PM Report Share #562527 Posted July 14, 2014 at 02:54 PM Boas! Ao tentar compilar o meu programa deu-me este erro: " $ gcc main_menu1.c -o main_menu1 main_menu1.c: In function ‘menu_admin’: main_menu1.c:97:30: error: expected expression before ‘int’ introduzir_temperaturas(int cid_temp[10][7]); ^ main_menu1.c:102:16: error: expected expression before ‘char’ nomenclar(char *cidades[MAX]); " declarei as duas funções como "void" e quando as inicializei pus assim: " introduzir_temperaturas(int cid_temp[10][7]); nomenclar(char *cidades[MAX]); " Alguem me consegue identificar o problema e ajudar? Cumprimentos! Link to comment Share on other sites More sharing options...
Mauro M. Posted July 14, 2014 at 05:20 PM Report Share #562535 Posted July 14, 2014 at 05:20 PM (edited) Boas! Ao tentar compilar o meu programa deu-me este erro: " $ gcc main_menu1.c -o main_menu1 main_menu1.c: In function ‘menu_admin’: main_menu1.c:97:30: error: expected expression before ‘int’ introduzir_temperaturas(int cid_temp[10][7]); ^ main_menu1.c:102:16: error: expected expression before ‘char’ nomenclar(char *cidades[MAX]); " declarei as duas funções como "void" e quando as inicializei pus assim: " introduzir_temperaturas(int cid_temp[10][7]); nomenclar(char *cidades[MAX]); " Alguem me consegue identificar o problema e ajudar? Cumprimentos! Posta a parte do código onde tens os erros usando as tags [ code ]. Edited July 14, 2014 at 05:21 PM by Mauro M. Link to comment Share on other sites More sharing options...
nelsonr Posted July 14, 2014 at 08:52 PM Report Share #562542 Posted July 14, 2014 at 08:52 PM Estás a definir o tamanho do array no parametro das funções? Link to comment Share on other sites More sharing options...
joaovilaca94 Posted July 15, 2014 at 08:56 PM Author Report Share #562604 Posted July 15, 2014 at 08:56 PM (edited) int menu_admin (ch) { printf ("===================================================\n"); printf ("===================================================\n"); printf ("== ESCOLHA UMA OPERAÇÃO A EXECUTAR ==\n"); printf ("===================================================\n"); printf ("===================================================\n"); printf ("== ==\n"); printf ("== 1 - Introduzir temperaturas ==\n"); printf ("== 2 - Dar nome às cidades ==\n"); printf ("== 3 - Voltar ao menu anterior ==\n"); printf ("== 4 - Sair ==\n"); printf ("== ==\n"); printf ("===================================================\n"); printf ("===================================================\n"); scanf("%d", &ch); switch(ch) { case 1: introduzir_temperaturas(int cid_temp[10][7]); break; case 2: nomenclar(char *cidades[MAX]); break; é nesta parte que me dá o erro $ gcc main_menu1.c -o main_menu1 main_menu1.c: In function ‘menu_admin’: main_menu1.c:97:30: error: expected exp<b></b>ression before ‘int’ introduzir_temperaturas(int cid_temp[10][7]); ^ main_menu1.c:102:16: error: expected exp<b></b>ression before ‘char’ nomenclar(char *cidades[MAX]); não consigo perceber qual é a expressão necessária antes do "int" e do "char"... Edited July 15, 2014 at 11:28 PM by thoga31 Tags code (p/ gcc output) + GeSHi Link to comment Share on other sites More sharing options...
Rui Carlos Posted July 15, 2014 at 08:58 PM Report Share #562605 Posted July 15, 2014 at 08:58 PM Uma chamada a uma função deve ser simplesmente introduzir_temperaturas(cid_temp);. A declaração da variável (e.g. int cid_temp[10][7];) deverá ser feita antes (preferencialmente no início da função). Rui Carlos Gonçalves Link to comment Share on other sites More sharing options...
joaovilaca94 Posted July 15, 2014 at 09:04 PM Author Report Share #562606 Posted July 15, 2014 at 09:04 PM Uma chamada a uma função deve ser simplesmente introduzir_temperaturas(cid_temp);. A declaração da variável (e.g. int cid_temp[10][7];) deverá ser feita antes (preferencialmente no início da função). tentei fazer a chamada da função só com introduzir_temperaturas(cid_temp); e o erro que deu foi exatamente o mesmo... Link to comment Share on other sites More sharing options...
Rui Carlos Posted July 15, 2014 at 10:07 PM Report Share #562609 Posted July 15, 2014 at 10:07 PM Isso é simplesmente impossível. No teu erro anterior aparecia: main_menu1.c:97:30: error: expected expression before ‘int’ introduzir_temperaturas(int cid_temp[10][7]); ^ que certamente agora não aparece, quer porque a linha está diferente, quer porque o int referido na mensagem de erro não está. Rui Carlos Gonçalves Link to comment Share on other sites More sharing options...
Mauro M. Posted July 16, 2014 at 01:10 PM Report Share #562650 Posted July 16, 2014 at 01:10 PM tentei fazer a chamada da função só com introduzir_temperaturas(cid_temp); e o erro que deu foi exatamente o mesmo... Provavelmente o erro passou para o case 2 visto que tens exatamente a mesma coisa. Declara as variáveis ANTES de chamares a funções. 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