Thread: Typical errors in C/C++ programming

  1. #1
    Registered User
    Join Date
    Apr 2016
    Posts
    4

    Post Typical errors in C/C++ programming

    As long as programming lives, the developers will make errors. Stepping on the same rake, they sometimes think that if code is working now, everything will be fine. But once they add an additional function or a condition, the error that seemed insignificant turns into a massive headache for the programmer and his colleagues.

    Some programmers cope the code fragments forgetting to change the necessary names and values. Others aren’t attentive reading the documentation, which gives a description of a function, or even don’t look at the documentation, hoping that the intuition won’t fail them. Others make the code too complex by creating macros in those fragments where simple functions could work well. There are plenty more examples like these ones.

    Of course it’s impossible to warn about all the possible ways to make an error, but it would be quite real to draw the attention to the most common error patterns. At least a person will know the variety of wrong paths to take and will be more careful, which will save time during the debugging and testing.

    There are plenty of resources that can help:


    Of course, it is be a drop in the ocean of useful information, but perhaps it would be enough to read during a weekend. Enjoy!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    *moved to C++ programming forum*

    Quote Originally Posted by el_programmer
    Typical errors in C/C++ programming
    In one of the articles that you linked to, you would have seen this answer by Stroustrup concerning "C/C++":

    Quote Originally Posted by Bjarne Stroustrup
    What do you think of C/C++?

    No that's not really a question I often get. In that sense, it is the only "fake FAQ" in this FAQ. However, it ought to be a FAQ because people use "C/C++" as if it meant something specific and as if they knew what it meant, leading to much confusion and misery. People should ask "What is C/C++?" and then on reflection stop using the term. It does harm.

    There is no language called "C/C++". The phrase is usually used by people who don't have a clue about programming (e.g. HR personnel and poor managers). Alternatively, it's used by people who simple do not know C++ (and often not C either). When used by programmers, it typically indicates a "C++ is C with a few useful and a lot of useless complicated features added" attitude. Often, that is the point of view of people who like to write their own strings and hash tables with little knowledge of the standard library beyond printf and memcpy. There are people who stick to a restricted subset of C++ for perfectly good reasons, but they (as far as I have noticed) are not the people who say "C/C++".

    I use C/C++ only in phrases such as "C/C++ compatibility" and "C/C++ community".
    As such, I recommend that when you have C specific material, you call it material for "C programming" and post in the C programming forum, whereas when you have C++ specific material, you call it material for "C++ programming" and post in the C++ programming forum. If the material applies to both, perhaps it should be tailored to C or C++ rather than presented in a one size fits all approach. If it is really truly general, then perhaps it should go in General Discussions or the Tech Board instead, depending on the kind of material.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    The Google C++ guide does little to help people actually be good at C+++.

  4. #4
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by MutantJohn View Post
    The Google C++ guide does little to help people actually be good at C+++.
    It does not exist to help you get better at C++.
    It is for stopping you from being too clever when working on a project.
    It certainly has parts that are archaic now, so it is better to consider it a general guideline and not the law.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The typical Largest smallest number printing
    By jannr in forum C Programming
    Replies: 21
    Last Post: 06-22-2011, 08:26 AM
  2. typical operations of an installer
    By stanlvw in forum Windows Programming
    Replies: 4
    Last Post: 05-30-2008, 08:07 AM
  3. typical access time of memory
    By Lind in forum Tech Board
    Replies: 5
    Last Post: 10-17-2007, 04:12 PM
  4. the typical * password thing
    By justforthis1 in forum C++ Programming
    Replies: 5
    Last Post: 10-26-2006, 01:48 PM
  5. typical error problem
    By stormy in forum C Programming
    Replies: 5
    Last Post: 11-12-2005, 06:28 PM

Tags for this Thread