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? :-(
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."
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."
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."
ups!
i have another question...
i have to fill data like name, address, etc...and when i was running my prog to test it, i was going to insert the name field, but it "jumped" and showed the address field :-(
Example:
I tryed to use fflush(stdin) but no result :-(Name:
Address: ...
And every time i run the program and enter a int value it crashes :-(
Last edited by IndioDoido; 03-20-2008 at 03:51 PM.
"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.*