0.3 — Introduction to C/C++

Before C++, there was C

The C language was developed in 1972 by Dennis Ritchie at Bell Telephone laboratories, primarily as a systems programming language (a language to write operating systems with). Ritchie’s primary goals were to produce a minimalistic language that was easy to compile, allowed efficient access to memory, produced efficient code, and was self-contained (not reliant on other programs). For a high-level language, it was designed to give the programmer a lot of control, while still encouraging platform (hardware and operating system) independence (that is, the code didn’t have to be rewritten for each platform).

C ended up being so efficient and flexible that in 1973, Ritchie and Ken Thompson rewrote most of the Unix operating system using C. Many previous operating systems had been written in assembly. Unlike assembly, which produces programs that can only run on specific CPUs, C has excellent portability, allowing Unix to be easily recompiled on many different types of computers and speeding its adoption. C and Unix had their fortunes tied together, and C’s popularity was in part tied to the success of Unix as an operating system.

In 1978, Brian Kernighan and Dennis Ritchie published a book called “The C Programming Language”. This book, which was commonly known as K&R (after the authors’ last names), provided an informal specification for the language and became a de facto standard. When maximum portability was needed, programmers would stick to the recommendations in K&R, because most compilers at the time were implemented to K&R standards.

In 1983, the American National Standards Institute (ANSI) formed a committee to establish a formal standard for C. In 1989 (committees take forever to do anything), they finished, and released the C89 standard, more commonly known as ANSI C. In 1990 the International Organization for Standardization (ISO) adopted ANSI C (with a few minor modifications). This version of C became known as C90. Compilers eventually became ANSI C/C90 compliant, and programs desiring maximum portability were coded to this standard.

In 1999, the ANSI committee released a new version of C called C99. C99 adopted many features which had already made their way into compilers as extensions, or had been implemented in C++.


C++ (pronounced see plus plus) was developed by Bjarne Stroustrup at Bell Labs as an extension to C, starting in 1979. C++ adds many new features to the C language, and is perhaps best thought of as a superset of C, though this is not strictly true (as C99 introduced a few features that do not exist in C++). C++’s claim to fame results primarily from the fact that it is an object-oriented language. As for what an object is and how it differs from traditional programming methods, well, we’ll cover that in chapter 8 (Basic object-oriented programming).

C++ was standardized in 1998 by the ISO committee (this means the ISO committee ratified a document describing the C++ language, to help ensure all compilers adhered to the same set of standards). A minor update was released in 2003 (called C++03).

Three major updates to the C++ language (C++11, C++14, and C++17, ratified in 2011, 2014, and 2017 accordingly) have been made since then, each adding additional functionality. C++11 in particular added a huge number of new capabilities, and at this point is widely considered the new baseline. As of the time of writing, C++20 is in the works, promising to bring even more new capabilities. Future upgrades to the language are expected every three or so years.

Each new formal release of the language is called a language standard (or language specification).

C and C++’s philosophy

The underlying design philosophy of C and C++ can be summed up as “trust the programmer” -- which is both wonderful and dangerous. C++ is designed to allow the programmer a high degree of freedom to do what they want. However, this also means the language often won’t stop you from doing things that don’t make sense, because it will assume you’re doing so for some reason it doesn’t understand. There are quite a few pitfalls that new programmers are likely to fall into if caught unaware. This is one of the primary reasons why knowing what you shouldn’t do in C/C++ is almost as important as knowing what you should do.

Q: What is C++ good at?

C++ excels in situations where high performance and precise control over memory and other resources is needed. Here are a few common types of applications that most likely would be written in C++:

  • Video games
  • Real-time systems (e.g. for transportation, manufacturing, etc…)
  • High-performance financial applications (e.g. high frequency trading)
  • Graphical applications and simulations
  • Productivity / office applications
  • Embedded software
  • Audio and video processing

Q: Do I need to know C before I do these tutorials?

Nope! It’s perfectly fine to start with C++, and we’ll teach you everything you need to know (including pitfalls to avoid) along the way.

Once you know C++, it should be pretty easy to learn standard C if you ever have the need. These days, C is mostly used for niche use cases: code that runs on embedded devices, when you need to interact with other languages that can only interface with C, etc… For most other cases, C++ is recommended.

0.4 -- Introduction to C++ development
0.2 -- Introduction to programming languages

212 comments to 0.3 — Introduction to C/C++

  • This is complite story of c++. Thanks.

  • Prashant

    Unclear -

    The underlying design philosophy of C and C++ can be summed up as “trust the programmer” -- which is both wonderful, because the compiler will not stand in your way if you try to do something unorthodox that makes sense, but also dangerous, because the compiler will not stand in your way if you try to do something that could produce unexpected results.

  • Sandy Bridges

    The second occurrence of "Ritchie" is misspelled as "Richie"

  • I disabled my ad blocker for you, and I would keep it disabled, except one of them messes with the page layout. I can deal with side banners, but I don't like ads messing with page layout. Ad blocker re-enabled for now. Sorry, but I can't stand layout disruption :-/

    I took a screenshot in case you need to see what I mean

    • Alex

      Yes, if you would be so kind as to contact me using the contact form, I'll reply via email. I'd love to see your screenshot. The ads aren't supposed to be disrupting the layout.

      • message sent. Let me know if there's anything else I can do to help. Like I said in the message, I don't mind disabling my ad blocker to support free content. I just don't like layout disruption; really messes with the eyes and such.

  • Roshan

    I feel I'm going deeper....

  • its me reddy

    i cant under stand anything so can you please help me to learn easily

    • Alex

      Probably not. :( This tutorial is written for readers with a certain level of proficiency in the English language, mathematics, and logic. If you don't have these things, then this tutorial is probably not for you.

  • Bob The Bulbasaur

    I plan to learn C++ so that I can mod Minecraft Windows 10 (written in C++) by modifying the game's code. Would that be possible?

    • Alex

      Unlikely. C++ executables are precompiled and are difficult to deconstruct. So unless they've provided a modding interface, I wouldn't expect you to be able to make much progress.

  • I'm really learning a lot. Even an 8 years old child is learning C++. Wonderful! The world is changing...and thinking where I am!!

  • david

    After reading this, and it’s very informative, I wonder how C came to be developed. Before C, there was only machine code and assembler, right? So… how was C developed? Did it come out of assembly or did the people actually use machine code or..? That is what I’m now pondering over.

  • My dear c++ Teacher,

    Please let me ask you whether, for learn graphics, I have to start from c++ graphics and then learn SDL, or directly learn SDL?
    With regards ad friendship.

    • Alex

      > I have to start from c++ graphics

      C++ doesn't have graphics. I think you meant to ask whether you should learn C++ and then SDL, or go straight to SDL. You should learn the basics of C++ first (at least up to chapter 7). At that point, you should have enough knowledge to start using SDL. After that point it's up to you whether you continue digging deeper into C++ or go in another direction.

  • Ryan Christian Rayo

    Dear teacher. I want to be a game developer in the future. I'm still having the trouble on what Language I should focus on. Should I go C++ first? or C? or I'd go Java first? or I don't need to learn languages because there are Game Engines?

    • Alex

      If you have a target game engine in mind, I'd learn whatever language or languages that game engine uses natively (unless it's C, in which case I'd learn C++ instead). That could be C++, C#, Lua, or something else.

      If you don't have an engine in mind, I'd probably start with C++ because it's versatile and the industry standard. Once you know one language, learning others will be a lot easier.

      • Ryan Christian Rayo

        I'm very much fond of using the Unity game engine(forgive if endorsing)... I don't if this is correct but I think they use C# language. is there any site you'd recommend me to learn c# teacher? thank you!

  • My dear c++ Teacher,

    Please suggest me a tutorial for learn graphics.

    With regards and friendship.

    • Alex

      What kind of graphics are you interested in doing? 2d? 3d? User interfaces?

      • My dear c++ Teacher,
        Please accept my many thanks for you responded my request and that immediately.
        I'm interested in 2d graphics, user interface, sound in, sound out. Especially a project that takes the voice of user, calculates, in real time, interval voice - note, that is voice error in respect to note, and present it on the screen. Indeed I have to use some dsp kit. Also user should hear note's sound.
        With regards and friendship.

        • Alex

          There's no easy answer to this question. To do such a thing, you'd probably need to use multiple libraries for assistance. One for 2d graphics, one for user interface, and one or more for sound. I might start with Simple DirectMedia Layer (SDL) and see what it can do for you, then add others libraries on top of it (for DSP and/or GUI).

          • My dear c++ Teacher,
            Please let me express my sincere gratitude for your suggestion. Already I have found by Google following tutorial for SDL. Do you recommend me that?
            With regards and friendship.

            • Alex

              I can't recommend any SDL tutorials because I'm not familiar with any of them. Try them, and see if they work for you. :)

        • Rafael A. A. Merlo

          Hey Georges Theodosiou, I believe that two resources made in C++ that can be extremely helpful in the project you described are the following:


          I found both playing the Steam game Crypt of the NecroDancer, and the secondary reason why I'm taking Alex wonderful tutorial is to know how to use them =)

  • DeCoder

    Guys, this site is the GAME CHANGER i was looking for i mean this is too good.

    A suggestion would you please give examples on the tutorial to try out....

    Alex May God Bless you and you may live forever   :-)

  • Sahil

    I think you should use easy words instead of hard ones for children like me who are in 6th standard

  • Justin263

    So I know some of C but I cant fined a complete tutorial on it. Will chapter 1-7 be a complete over view of C before C99? If not then do you know a tutorial as in depth and as detailed as this one?
    I have a feeling when I finish this tutorial I will have a complete under standing of C++ and I wont need any other resources on my way to learning this language other than practice and getting familiar with the Library. Do you feel like this is true? Or will there be more to learn about the language?

    • Alex

      > Will chapter 1-7 be a complete over view of C before C99?

      No. All chapters in this tutorial are focused on modern C++, and you don't need to know C to learn C++. By the time you finish these tutorials, you'll have a good understanding of most C++ fundamentals and hopefully will never want to use C again. :)

  • My dear c++ Teacher,
    Please let me this question. I click on ads just for you get some cents. My question: Have I to wait till ads be fully downloaded? or is it enough that its URL be visible?
    Also let me ask about INTEL's compiler ads. I read it. Do you use it?
    With regards and friendship.

    • Alex

      I don't know how Google counts ad views. But thank you for your patronage.

      I do not use Intel's compiler personally.

      • My dear c++ Teacher,
        Please let me say that I'm homeless in France and forced to travel from town to town. I get internet access in municipal libraries or social services. Just now I am in "Maison de formation" of the town Clamecy. Yesterday I did click on all of your site ads. Today ads appear and quickly disappear. Indeed in the next town I will be able to click on your site ads.
        With regards and friendship.

  • shorouk

    This is just wonderful. Thanks a lot

  • Devvrat Singh

    What a great tutorial Sir.. God bless you!
    A humble suggestion. I think it should be (after the authors' last names) instead of (after the author's last names). Cheers! :)

  • Awesome man, I will learn it till end

  • pandanielak

    Hey Alex,
    I wonder if You've ever considered making a live chat. For me (little more than total newbie) it seems like a nice idea to be able to ask and talk in real time. Although it depends how many viewers You have at a time.

  • Leander

    Can't believe C dates as far back as 1972 O_o

  • Kianaush Rahbary

    I hoped that I could find a book for starting, but every book that I wanted to open, at first wanted a payment.
    I can't pay.
    so, ...

  • Expect more of the articles so impressed. is so outstanding, this community needs people like your enthusiasm

  • Gorador

    this is great I love it

  • Vaibhav

    Hi Alex,
    Is it possible to add an image in C++ program?? If yes, how do you do it?!

    • Alex

      Yes, it sure is possible. But doing graphics stuff isn't part of the core C++ functionality -- you'll need a 3rd party library for that. A few examples on those are Qt, WxWidgets, and SDL -- all should have methods for loading and displaying images.

    • Vaibhav

      Is there a simpler solution to this?? Cause I don't know the use of above mentioned softwares. Isn't there some code that can simply add the image file from memory??

      • Alex

        In C++, you really have to use a 3rd party library. There are plenty of options, some more complicated than others.

        If you want something super-simple and built into the language itself, then perhaps C++ isn't the right language for you -- maybe try Java or C#.

  • GEScott71

    Thank you for the history.  The most interesting to me was the "trust the programmer" philosophy.  I am looking forward to learning what not to do!

  • fagner

    Guys, this website is very helpful. I am clicking in all ads, so the developers keep up with the great work. Good studies for you all.

  • Sai

    good article thanks for sharing such a wonderful information

  • Roopa Rathinam

    thank u for leaving this page.... i really dnt no abt c and c++ language
    now i knw abut dennis ritchie and c, c++...thank u

Leave a Comment

Put all code inside code tags: [code]your code here[/code]