Skip to the content of the web site.

C Programming

IEEE Spectrum Magazine    MIT Technology Review    Wired Magazine    EDN Network    EE Times    Skeptic's Guide to the Universe

Authors: Douglas Wilhelm Harder and Prof. Patel

In many cases, when programming real-time, embedded or operating systems, the memory overhead of C++ can be unnecessarily excessive. Consequently, embedded systems and operating systems (and some larger real-time systems) are still programmed in C. This section will look at the differences between C and C++. There are some aspects of C++ that are not available in C, such as

  • classes,
  • templates,
  • pass-by-reference,
  • nullptr (C uses NULL),
  • new and delete,
  • namespaces,
  • robust exception handling,
  • operator or function overloading,
  • private member variables,
  • the C++ standard libraries and standard template libraries, and
  • specifically the std::string class.

You may therefore observe that while C++ is primarily object-oriented, C is procedural, meaning that you solve problems by determining the appropriate sequence of function calls, as opposed to object-oriented programming where you solve problems by determining what manipulations must be performed on what data.

Now, that is not to say that you cannot use an object-oriented approach in C; it is only that there are no language features to assist or enforce an object-oriented approach. For example, you can choose to only access the member variables of a structure through function calls, but there is no mechanism in place to prevent you from accidentally accessing a member variable when you meant to use a function call.

The topics in this section will give you the initial tools you will need to program in C, as opposed to C++, including

  1. a reduced set of keywords,
  2. stdio.h,
  3. initialization is only through assignment
  4. declarations must occur outside the control sequence of a for loop,
  5. pass-by-address,
  6. stripped-down structures and type definitions,
  7. NULL,
  8. malloc(...) and free(...),
  9. null-character–terminated strings,
  10. built-in Boolean type,
  11. built-in complex numbers,
  12. writing generic data structures,
  13. other libraries.