This lecture gives you the briefest introduction to C from a C++ point of view. If you need to use this language, read an introductory book (. K&R). This lecture gives you a hint what to look for. C is C++’s closest relative, and compatible in many areas, so much of your C++ knowledge carries over. | Chapter 27 The C Programming Language Bjarne Stroustrup Dennis M. Ritchie Abstract This lecture gives you the briefest introduction to C from a C++ point of view. If you need to use this language, read an introductory book (. K&R). This lecture gives you a hint what to look for. C is C++’s closest relative, and compatible in many areas, so much of your C++ knowledge carries over. Stroustrup/PPP - Dec'13 Overview C and C++ Function prototypes printf()/scanf() Arrays and strings Memory management Macros const C/C++ interoperability ABIs An example Stroustrup/PPP - Dec'13 C and C++ Both were “born” in the Computer Science Research Department of Bell Labs in Murray Hill, NJ dmr ken bwk bs doug Stroustrup/PPP - Dec'13 Modern C and C++ are siblings Stroustrup/PPP - Dec'13 C++11 C11 C++14 C and C++ In this talk, I use “C” to mean “ISO C89” That’s by far the most commonly used definition of C Classic C has mostly been replaced (though . | Chapter 27 The C Programming Language Bjarne Stroustrup Dennis M. Ritchie Abstract This lecture gives you the briefest introduction to C from a C++ point of view. If you need to use this language, read an introductory book (. K&R). This lecture gives you a hint what to look for. C is C++’s closest relative, and compatible in many areas, so much of your C++ knowledge carries over. Stroustrup/PPP - Dec'13 Overview C and C++ Function prototypes printf()/scanf() Arrays and strings Memory management Macros const C/C++ interoperability ABIs An example Stroustrup/PPP - Dec'13 C and C++ Both were “born” in the Computer Science Research Department of Bell Labs in Murray Hill, NJ dmr ken bwk bs doug Stroustrup/PPP - Dec'13 Modern C and C++ are siblings Stroustrup/PPP - Dec'13 C++11 C11 C++14 C and C++ In this talk, I use “C” to mean “ISO C89” That’s by far the most commonly used definition of C Classic C has mostly been replaced (though amazingly not completely) C99 is not yet widely used, C11 may be catching on Source compatibility C is (almost) a subset of C++ Example of exception: int f(int new, int class, int bool); /* ok in C */ (Almost) all constructs that are both C and C++ have the same meaning (semantics) in both languages Example of exception: sizeof('a') /* 4 in C and 1 in C++ */ Link compatibility C and C++ program fragments can be linked together in a single program And very often are C++ was designed to be “as close as possible to C, but no closer” For ease of transition For co-existence Most incompatibilities are related to C++’s stricter type checking Stroustrup/PPP - Dec'13 C and C++ Both defined/controlled by ISO standards committees Separate committees Unfortunately, leading to incompatibilities Many supported implementations in use Available on more platforms than any other languages Both primarily aimed at and are heavily used for hard system programming tasks, such as Operating systems kernels .