Pass a string (char array) instead of a char as the argument. But again, do not use gets(). Use something like fgets() instead.i'm new in this, what must i do to resolve that warning?
Pass a string (char array) instead of a char as the argument. But again, do not use gets(). Use something like fgets() instead.i'm new in this, what must i do to resolve that warning?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
how about now:
Code:Medico inserirMedico() { Medico temp; //variável temporária int i; printf("\nNome: "); fgets(temp.nome,sizeof temp.nome,stdin); printf("\nMorada: "); fgets(temp.morada,sizeof temp.nome,stdin); printf("\nContacto: "); fgets(temp.contacto,sizeof temp.contacto,stdin); printf("\nEspecialidade: "); fgets(temp.especialidade,sizeof temp.especialidade,stdin); printf("\nID de Medico: "); fgets(temp.idMedico,sizeof temp.idMedico,stdin); printf("\nHorario Semanal (1-Manha | 2-Tarde | 3-Dia Todo)\n"); for(i=0; i<5; i++) { if(i==0) { printf("\nHorario para Segunda-Feira: "); fgets(temp.horarioTrab[i].hora,sizeof temp.horarioTrab[i].hora,stdin); temp.horarioTrab[i].dia = 2; } if(i==1) { printf("\nHorario para Terca-Feira: "); fgets(temp.horarioTrab[i].hora,sizeof temp.horarioTrab[i].hora,stdin); temp.horarioTrab[i].dia = 3; } if(i==2) { printf("\nHorario para Quarta-Feira: "); fgets(temp.horarioTrab[i].hora,sizeof temp.horarioTrab[i].hora,stdin); temp.horarioTrab[i].dia = 4; } if(i==3) { printf("\nHorario para Quinta-Feira: "); fgets(temp.horarioTrab[i].hora,sizeof temp.horarioTrab[i].hora,stdin); temp.horarioTrab[i].dia = 5; } if(i==1) { printf("\nHorario para Sexta-Feira: "); fgets(temp.horarioTrab[i].hora,sizeof temp.horarioTrab[i].hora,stdin); temp.horarioTrab[i].dia = 6; } } temp.numPacientes = 0; return temp; }How? :-(Pass a string (char array) instead of a char as the argument.
"Artificial Intelligence usually beats natural stupidity."
i resolved the char to char array warnings :-D thanks alot, but i still get warnings in the int:
warning C4047: 'function' : 'char *' differs in levels of indirection from 'int'
warning C4024: 'fgets' : different types for formal and actual parameter 1
warning C4047: 'function' : 'char *' differs in levels of indirection from 'int'
warning C4024: 'fgets' : different types for formal and actual parameter 1Code:printf("\nContacto: "); fgets(temp[n].contacto,sizeof(temp[n].contacto),stdin); //<--- int printf("\nID de Medico: "); fgets(temp[n].idMedico,sizeof(temp[n].idMedico),stdin); //<--- int
"Artificial Intelligence usually beats natural stupidity."
What are you trying to read into? If you are not trying to read into a string, gets(), fgets(), etc, are all wrong approaches.How? :-(
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Code:typedef struct { enum diaSemana dia; char hora; }Horario;Medico listaMedico[10];Code:typedef struct medico { char nome[200]; char morada[300]; int contacto; char especialidade[100]; int numPacientes; int idMedico; Horario horarioTrab[5]; }Medico;
I'm trying to save data into listaMedico
"Artificial Intelligence usually beats natural stupidity."
all done :-)
once again thanks...
by the way...
if gets() is bad, why do teachers reference it and not fgets()? And why do compilers still use it?
"Artificial Intelligence usually beats natural stupidity."
Lack of knowledge?if gets() is bad, why do teachers reference it and not fgets()?
backward compatibilityAnd why do compilers still use it?
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
Probably because their textbook of choice is 20 years old.
Mainframe assembler programmer by trade. C coder when I can.
Lol...ok :-D
going to start using fgets() at all times.
Tnx alot everyone for the help :-)
"Artificial Intelligence usually beats natural stupidity."
You may want to spend some time in the FAQ.
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*