Thread: I need help to compile this code...

  1. #16
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    You can't just replace all occurances of "gets" with "fgets" in your code. (The errors are because fgets takes an extra parameter.) Try this:
    char s[SOMETHING], *p;
    fgets(s, sizeof(s), stdin);
    if((p = strchr(s, '\n'))) *p = 0;
    Note that s must be an array and you must have included <string.h>.

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  2. #17
    wise_ron wise_ron's Avatar
    Join Date
    May 2006

    thanks for you help guys

    thank you guys this forum Rocks!

  3. #18
    Fountain of knowledge.
    Join Date
    May 2006
    I am assuming gets reads standard input so you need to
    tell fgets that so...par example


    would become


    Basically you are telling fgets which file to read.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code won't compile
    By monkles in forum C Programming
    Replies: 3
    Last Post: 05-28-2009, 01:45 PM
  2. Compile Errors in my Code. Can anyone help?
    By DGLaurynP in forum C Programming
    Replies: 1
    Last Post: 10-06-2008, 09:36 AM
  3. This code won't compile in Red Hat Linux 9
    By array in forum Linux Programming
    Replies: 7
    Last Post: 04-27-2004, 06:30 AM
  4. << !! Posting Code? Read this First !! >>
    By kermi3 in forum Linux Programming
    Replies: 0
    Last Post: 10-14-2002, 01:30 PM
  5. How do they compile code for an OS ?
    By Nutshell in forum A Brief History of
    Replies: 49
    Last Post: 03-28-2002, 12:16 AM