Thread: gets debug

  1. #1
    Registered User
    Join Date
    Jul 2002

    gets debug

    Well I guess I'm too isolated from the real world to know about the
    long known problems with "gets".

    I debugged this on my PC not on Unix.

    I loaded a real old version of TC to get the oldest compiler I could
    and made a real simple test program using "gets". Sure enough it
    caused problems if I entered too many characters. "Strlen" always
    reported the string length as 127 no matter how I defined the string
    array( char input[25] or char input[128] or char input[1024]. The
    string length was always 127 even if I held a key down for 2 minutes,
    must be a keyboard buffer limit.

    I got an illegal instruction message a couple of times and the TC blew
    up a couple of times.

    I think the reason I've never encountered this before is that we don't
    sell of otherwise distribute our software and it's always used in a
    very controlled environment.

    I'll go back to the Kernighan & Rithcie book to find a safer command.
    Any suggestions?

    Thanks for the help.

  2. #2
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Bangalore, India
    That's where fgets() plays it's role. It reads only maximum number of characters specified to be read, and not more, thus avoiding buffer overflow.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Binary not built with debug info - why?
    By ulillillia in forum C Programming
    Replies: 15
    Last Post: 12-11-2008, 01:37 AM
  2. makefiles - debug & release?
    By cpjust in forum C Programming
    Replies: 6
    Last Post: 10-26-2007, 04:00 PM
  3. Debug --> Exceptions in Visual Studio 2005
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 08-10-2007, 02:12 AM
  4. Results in Debug and Release mode are different
    By jaro in forum C Programming
    Replies: 11
    Last Post: 05-27-2006, 11:08 AM
  5. Ask about Debug Assert Failed
    By ooosawaddee3 in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2002, 11:07 PM