Most people who practice most days can learn the basics of C++ in three months. How far that gets you depends on your starting point, how many hours you can give each week, and what you want to build. This site covers C++, so this article answers for C++. If you mean C, the early months look much the same, but C has no classes, references or templates, so the later topics differ.
What three months can cover
The plan below is a rough guide, not a promise. Each step builds on the last one.
- Month one: installing a compiler, writing and running programs, variables and types, operators,
ifstatements and loops, and writing functions. - Month two: arrays, strings,
std::vector, pointers and references, and simple classes. - Month three: reading and writing files, standard algorithms such as
std::sort, using a debugger, and building a small project from start to finish.
By the end, many learners can write small programs without copying examples line by line. Templates, move semantics and concurrency usually take longer to feel comfortable with.
How many hours a week?
There is no fixed number. Regular practice works better than long, rare sessions, because you return to ideas before you forget them. An hour on most days is a common goal. A few hours a week is a reasonable start, though progress will be slower. Typing programs yourself and fixing what breaks teaches more than reading examples alone.
What makes the first months harder
- Compiler errors can be long. Start with the first line that names your file and line number.
- Pointers take time. They are a common source of confusion in the second month.
- Some mistakes compile and still go wrong. C++ treats many of them as undefined behavior, so a program can give wrong results or crash.
- There are several ways to do the same job. Pick one style for a while before you widen your range.
Signs you are on track
- You can write a loop-based program from a blank file.
- You can find the line a compiler error points to and fix it.
- You can explain what a function’s parameters and return value mean.
- You can read a short program and predict its output most of the time.
Making the time count
Small projects teach more than reading alone. Try a number-guessing game, a to-do list saved to a file, or a simple bank account class. Compile with warnings turned on, using -Wall -Wextra with GCC or Clang, and read every warning. When a program misbehaves, a debugger shows you the values as the program runs. Sanitizers such as -fsanitize=address,undefined can catch memory errors while the program runs.
If you are coming from Python
If you already write Python, the ideas of loops and functions carry over. Most of the extra time goes to types, memory and the compile step. Learning c after python is a common path, and the first months usually feel slower than they did in Python.
Bottom line
Three months is enough to get comfortable with the basics of C++ and to write small programs on your own. It is rarely enough to feel fluent in the whole language. Plan for more time if you want templates or concurrency.