1
The following problem
expected Expression before 'eqp'
at the line of the data function where the value is read and I could not identify the reason for this.
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
typedef struct equipamento{
int codigoequipamento;
int tempoativo;
float potencia;
float consumonomes;
char equipamento[30];
}eqp;
typedef struct equipamento eqp;
void menu(void);
void dados(void);
int main(){
setlocale(LC_ALL, "Portuguese");
int resp=0;
do{
menu();
scanf ("%d",&resp);
if(resp == 1){ // Para caso deseje-se cadastrar
dados();
}if(resp == 2){// Caso deseje-se consultar oq já foi cadastrado
}if(resp == 3){
break;
}if((resp > 3) || (resp < 1)){
printf("Valor invalido\n");
}
}while (resp != 3);
return 0;
}
void menu(void){ //menu
printf("---------------------------------------\n");
printf("| Sessão de cadastro de equipamentos |\n");
printf("---------------------------------------\n");
printf("Digite 1 para cadastrar\n");
printf("Digite 2 para consultar os cadastros\n");
printf("Digite 3 para sair\n");
}
void dados(void){ // Função para ler dados
printf("Entre com o codigo do equipamento: ");
scanf("%d",&eqp.codigoequipamento);
}
When reading the data you used the "->", could you tell me what concept this involves? p.s: It helped a lot, thank you.
– Caroline Marx
'->' is used whenever the value on the right is an address, and'&' represents "address"; so when using '&' before the variable as it was done in "&equipment" '->' should be used with "&equipment->code". @Carolinemarx
– Drinjer
@CarolineMarx https://answall.com/q/325987/101 e https://answall.com/a/51204/101
– Maniero