Getting Started with C or C++
Exactly How to Get Started with C/C++ TodayOkay, let's cut to the chase--you want to learn to program in C/C++ and you want to know exactly what you should do, right now.
I'd strongly recommend you buy my ebook, Jumping into C++, which will take you from absolutely nothing to getting a full working environment, all the core C++ syntax, lots of tips on how to design your programs, sample code, practice problems, quizzes and advanced C++ class design stuff too. You can check out a sample chapter or buy now.
Alternatively, you can take a web-only route:
If you prefer physical books, you can find Jumping into C++ on Amazon, where it currently sports a 4.5 star rating!
If run into problems, take a look at these articles:
The rest of this page provides answers to some of the most common questions new programmers have about C, C++ and programming.
What is C, What is C++, and What is the Difference?C is a programming language originally developed for developing the Unix operating system. It is a low-level and powerful language, but it lacks many modern and useful constructs. C++ is a newer language, based on C, that adds many more modern programming language features that make it easier to program than C.
Basically, C++ maintains all aspects of the C language, while providing new features to programmers that make it easier to write useful and sophisticated programs.
For example, C++ makes it easier to manage memory and adds several features to allow "object-oriented" programming and "generic" programming. Basically, it makes it easier for programmers to stop thinking about the nitty-gritty details of how the machine works and think about the problems they are trying to solve.
So, what is C++ used for?C++ is a powerful general-purpose programming language. It can be used to create small programs or large applications. It can be used to make CGI scripts or console-only DOS programs. C++ allows you to create programs to do almost anything you need to do. The creator of C++, Bjarne Stroustrup, has put together a partial list of applications written in C++.
How do you learn C++?No special knowledge is needed to learn C++, and if you are an independent learner, you can probably learn C++ from online tutorials or from books. There are plenty of free tutorials online, including Cprogramming.com's C++ tutorial - one which requires no prior programming experience. You can also pick out programming books from our recommendations.
While reading a tutorial or a book, it is often helpful to type - not copy and paste (even if you can!) - the code into the compiler and run it. Typing it yourself will help you to get used to the typical typing errors that cause problems and it will force you to pay attention to the details of programming syntax. Typing your program will also familiarize you with the general structure of programs and with the use of common commands. After running an example program - and after making certain that you understand how it works - you should experiment with it: play with the program and test your own ideas. By seeing which modifications cause problems and which sections of the code are most important to the function of the program, you should learn quite a bit about programming.
Try our C++ Beginner to C++ Expert recommended book series, a six-book set designed to get you maximal information and help take you from beginner to C++ master.
You may also want to read about The 5 Most Common Problems New Programmers Face--And How You Can Solve Them.
What do I need to start programming in C or C++?In order to make usable programs in C or C++, you will need a compiler. A compiler converts source code - the actual instructions typed by the programmer - into an executable file. Numerous compilers are available for C and C++.
Can you help me set up a compiler?Absolutely! For beginners, Code::Blocks with MinGW is our recommended free and easy-to-use Windows compiler. For OS X, I recommend Apple XCode, and for Linux, g++. All of these links will help you get up and running and ready to start programming.
Do I need to know C to learn C++?No. C++ is a superset of C; (almost) anything you can do in C, you can do in C++. If you already know C, you will easily adapt to the object-oriented features of C++. If you don't know C, you will have to learn the syntax of C-style languages while learning C++, but you shouldn't have any conceptual difficulties.
What's the point of learning to program? What can I get out of it?Ah, a skeptic! You can get a lot of things out of programming. For one thing, it's just plain fun. You can read my opinion on the matter here: Why Learn to Program?
I want to make games in C++, what should I do?It may be a challenging road, but it is doable. This article has more information: so you want to be a game Programmer?
When you've learned a bit of C++, don't miss Same Game - a Simple Game from Start to Finish which will teach you to create a game, starting from nothing and ending in a fully playable game.
What does it take to learn to be a programmer?Great question! Here's an article about what it takes to be a programmer!
Do I need to know math to be a programmer?No! At least, not too much. Most of programming is about design and logical reasoning, not about being able to quickly perform arithmetic, or deeply understanding algebra or calculus. The carryover between math and programming are primarily around logical reasoning and precise thinking. Only if you want to program advanced 3D graphics engines, or do other specialized numerical programming will you need mathematical skill.
How should I think about Program Design?Try Thinking about Programming - A Beginner's Guide
Help, my program doesn't work!Take a look at a list of common programming mistakes, send us an email or, if you're really stuck, join our message board or ask an expert!
Where can I learn more about the history of computer science?Try this article on computer science.
Why do I want to learn CTry this article on why learn C.