Juin Posted December 31, 2009 at 02:08 PM Report Share #303429 Posted December 31, 2009 at 02:08 PM Boas, estou a ter um erro e não estou a perceber o porquê. Se puderem ajudar, aqui vai. typedef struct{ char urgencia[NCHAR]; }Livro; void Add(){ int op; Livro dados; do{ printf("Urgencia: \n\t1. Nao Urgente\n\t2. Urgente\n\t3. Muito Urgente\n"); printf("Introduza 1, 2 ou 3 de acordo com a sua escolha: "); scanf(" %d", &op); switch (op){ case 1: printf("Nao Urgente selecionado.\n"); dados.urgencia[NCHAR]= "Nao Urgente"; //ERRO break; case '2': printf("Urgente selecionado.\n"); dados.urgencia[NCHAR] = "Urgente"; //ERRO break; case '3': printf("Muito Urgente selecionado.\n"); dados.urgencia[NCHAR] = "Muito Urgente"; //ERRO break; default: printf("Tem de seleccionar um numero valido. Escolha de 1, 2 ou 3.\n");break; } }while(op<1 && op>3); return dados; } funcoes.c:52: warning: assignment makes integer from pointer without a cast funcoes.c:55: warning: assignment makes integer from pointer without a cast funcoes.c:58: warning: assignment makes integer from pointer without a cast Não estou a perceber o que estará mal. Link to comment Share on other sites More sharing options...
Juin Posted December 31, 2009 at 02:09 PM Author Report Share #303430 Posted December 31, 2009 at 02:09 PM A Função é do tipo Livro e não void passei mal... Link to comment Share on other sites More sharing options...
Baderous Posted December 31, 2009 at 02:10 PM Report Share #303431 Posted December 31, 2009 at 02:10 PM A atribuição de valores a strings não se faz com o operador '=' mas sim com funções como a strcpy e strdup. Link to comment Share on other sites More sharing options...
Localhost Posted December 31, 2009 at 02:15 PM Report Share #303433 Posted December 31, 2009 at 02:15 PM E não uses o indice quando fores a fazer o assignment #include <stdio.h> #include <string.h> int main(void){ char name[10]; strncpy(name,"hello",10); // Não uses a strcpy, é insegura. return 0; } here since 2009 Link to comment Share on other sites More sharing options...
Juin Posted December 31, 2009 at 02:33 PM Author Report Share #303435 Posted December 31, 2009 at 02:33 PM Obrigado, resulta 🙂 Link to comment Share on other sites More sharing options...
Localhost Posted December 31, 2009 at 03:06 PM Report Share #303442 Posted December 31, 2009 at 03:06 PM De nada, sempre às ordens 🙂 here since 2009 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