warning C4013...errrrrr!

This is a discussion on warning C4013...errrrrr! within the C Programming forums, part of the General Programming Boards category; How? :-( What are you trying to read into? If you are not trying to read into a string, gets(), ...

  1. #16
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,303
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #17
    Registered User IndioDoido's Avatar
    Join Date
    Apr 2007
    Posts
    194
    Code:
    typedef struct
    {
    	enum diaSemana dia;
    	char hora;
    }Horario;
    Code:
    typedef struct medico
    {
    	char nome[200];
    	char morada[300];
    	int contacto;
    
    	char especialidade[100];
    	int numPacientes;
    	int idMedico;
    
    	Horario horarioTrab[5];
    
    }Medico;
    Medico listaMedico[10];

    I'm trying to save data into listaMedico
    "Artificial Intelligence usually beats natural stupidity."

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,022
    Quote Originally Posted by IndioDoido View Post
    How? :-(
    Like you've done with Nome and Morada.
    Code:
    int main()
    {
    	char c;
    	fgets(c, sizeof(c), stdin); /* Bad! */
    	char array[100];
    	fgets(array, sizeof(array), stdin); /* Good! */
    }
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    Registered User IndioDoido's Avatar
    Join Date
    Apr 2007
    Posts
    194
    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 1
    Code:
    		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."

  5. #20
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,022
    fgets wants a char*, a char array, not an int.
    You can't read into an integer with fgets.
    Since you are reading integer input, I would say the easiest way is scanf.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #21
    Registered User IndioDoido's Avatar
    Join Date
    Apr 2007
    Posts
    194
    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."

  7. #22
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    if gets() is bad, why do teachers reference it and not fgets()?
    Lack of knowledge?

    And why do compilers still use it?
    backward compatibility
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  8. #23
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    Probably because their textbook of choice is 20 years old.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  9. #24
    Registered User IndioDoido's Avatar
    Join Date
    Apr 2007
    Posts
    194
    Lol...ok :-D

    going to start using fgets() at all times.

    Tnx alot everyone for the help :-)
    "Artificial Intelligence usually beats natural stupidity."

  10. #25
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,274
    Quote Originally Posted by IndioDoido View Post
    Now i get 16 warnings:
    Excellent. That means the header file is doing what it is supposed to -- revealing programming errors which would otherwise go unnoticed.

  11. #26
    Registered User IndioDoido's Avatar
    Join Date
    Apr 2007
    Posts
    194
    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:
    Name:
    Address: ...
    I tryed to use fflush(stdin) but no result :-(

    And every time i run the program and enter a int value it crashes :-(
    Last edited by IndioDoido; 03-20-2008 at 04:51 PM.
    "Artificial Intelligence usually beats natural stupidity."

  12. #27
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    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.*

  13. #28
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,022
    Never use fflush(stdin) and showing the code helps more than a thousand words.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 07-10-2008, 04:45 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21