Thread: gets() not so bad

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by MK27 View Post
    Terrific! BUT MICROSOFT IS NOT ANSI OR THE ISO.

    Okay, so in house MS can ban the use of these functions. Or use strict C++ or Java or whatever. The rest of use will just have to toughen up and learn to use your brain whilst coding, because all three of those functions are perfectly safe when used properly.
    I'm not saying to use Microsoft functions. I'm saying to create your own safe functions that add security checks so that you don't commit to these mistakes.
    That's why I said it would be nice is safe alternatives were added to the language (in the standard, of course).

    Quote Originally Posted by Bayint Naung View Post
    Microsoft to banish memcpy
    next time, Assignment operator ?maybe
    They're only banning it in their internal development. This doesn't affect the rest of the world's C programmers.
    (Though they should take a hint and consider security.)
    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.

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Elysia View Post
    I'm not saying to use Microsoft functions. I'm saying to create your own safe functions that add security checks so that you don't commit to these mistakes.
    That's why I said it would be nice is safe alternatives were added to the language (in the standard, of course).
    This is completely unnecessary. 95% of memcpy calls can be done without checks simply by setting up the input and output correctly.

    Please do not say "oh but what if I do this":
    Code:
    char buffer[16];
    memcpy(buffer, something_else, 1000000);
    That is JUST STUPID. TOO BAD. YOU LOSE. LEARN TO PROGRAM.

    This is only a problem in "real world" settings like MS where economics and scale have made $$$ the priority, so quality of the product (and the people who produce it) is second seat to the quantity they can produce. That's what needs to be fixed.

    Since it won't be, they can just make C# faster or something. Won't happen if half the underlying code is totally redundant safety checks, of course.
    Last edited by MK27; 06-11-2010 at 10:50 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by MK27 View Post
    This is completely unnecessary. 95% of memcpy calls can be done without checks simply by setting up the input and output correctly.
    ...And one day you'll shoot yourself in the foot because you didn't think right. You introduced a bug. The bug didn't crash the program and you got a buffer overrun. Yay.
    ...Of course, this could have been prevented in the first place had you used safety checks.
    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. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Elysia View Post
    ...And one day you'll shoot yourself in the foot because you didn't think right. You introduced a bug. The bug didn't crash the program and you got a buffer overrun. Yay.
    ...Of course, this could have been prevented in the first place had you used safety checks.
    Can happen, but:

    1) I use a memchecker.
    2) I'm very aware of the issue, so I'm used to dealing with it. If you want some tips just ask!

    Analogy: If no one ever takes the training wheels off your bike, it will be hard for you to ride around without them.

    Does that mean it is oh so hard for people to ride around with no training wheels?!?? Hmmm...
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. bad and fail of steam
    By George2 in forum C++ Programming
    Replies: 8
    Last Post: 02-19-2008, 03:07 AM
  2. Can you still view the bios screen with a bad CPU?
    By HyperCreep in forum Tech Board
    Replies: 4
    Last Post: 12-31-2006, 06:57 PM
  3. Replies: 6
    Last Post: 11-12-2005, 11:57 AM
  4. Bad coding habits
    By Magos in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 09-12-2005, 05:44 PM
  5. Shocking(kind of)
    By Shadow in forum A Brief History of Cprogramming.com
    Replies: 25
    Last Post: 12-10-2002, 08:52 PM