I’ve avoided being specific here for a couple reasons.
The main one is that, if you’ve properly selected your learning source material then it will provide good examples at your level (if it doesn’t, find more suitable learning material). That book comes with examples in it, and you can try them and try variations on them. It’s targeted at beginners and starts from the ground up.
The other reason is that you said that your goal was to learn C which is fairly low level. Sometimes, it can feel like you’re trying to build a skyscrapers with tweezers even when you know what you’re doing. Deciding whether C is the best tool for a particular job is a whole separate discussion. For the purposes of learning a particular language its less important if it would have been simpler in a different one (say Java, or Python). In this case, you need to additionally learn how to prune/stub out bits that are secondary to the task at hand.
With many of the suggestions you could get stuck before you even start. For example, even to sort a list of strings begs many difficult questions for beginners. Where did they come from? Did you read them from a file (standard input, fopen, std::cin, etc)? Where did you put them (array, vector, list, etc)? What even were they (char*, std::string, etc)? How do you even sort, (implement a sort, use a library, etc)? Then what do you do when you get a compile error that you don’t understand? Pretty soon someone tells you that you should be breaking your code into multiple files and using a build tool like “make” to put it together incrementally. None of those are challenging problems later but in the beginning you could find yourself off in the weeds with no sense of how to get back to what you understand. This is way you would want to favor using the examples from the learning source as they are designed to use what has been explained so far and avoid features that have yet to be explained. This is what I meant by it being a bit of an art.
Obviously, you’ll want to take the training wheels off at some point (just with C you might wan’t to leave them on a bit longer than other languages). When you do get enough of the basics down, here are some practical ways you can cut corners while learning to simplify the process.
- Favor adding your program inputs as static data
- your program will do the same thing every time, but who cares
- no need to understand files or streams, you can defer this
- no need to parse text, your data can be data structures ready to go in memory
- Favor console applications
- don’t bother with gui or any graphics until you have a solid grasp of the basics
- Avoid using std::cin std::cout
- just use C style calls like printf()
- they’re conceptually simpler and cin/cout are terribly designed and often avoided in practice.
- Put all your code in one file
- build and link your entire program with a single command
- its very simple (and fast)
- no build tool required (and no troubleshooting incomplete incremental build mechanism)
- even if you really want to break things up, just make a “bulk.cpp” files that includes all your loose cpp files and build that
- Don’t use an IDE (just text editor and command line)
- no need to learn how to set up a project
- better to understand exactly what is going on for now
- using tip #4 makes this a cinch
fase
- Avoid containers
- containers are great, don’t write your own without a good reason
- you have a good reason, learn to build them, learn how they work/perform
- one of the main points of using C is to get direct access to memory, learn how to deal with memory and pointers
Here are couple ideas to get you started
- create a static array of ints and print them out to the console
- create a function to reverse all elements in a the list, print the list before and after calling the reverse function
I was referring to the functionality of programs you will write (not the topics I listed). Programs useful for learning to program are typically fairly trivial. Conversely, programs which are themselves useful are rarely trivial.
As for the list of topics I gave, I thinks its all useful depending on what you need to do. So it could be considered both fairly extensive or horribly incomplete depending on your viewpoint. For example, I didn’t even mention design patterns as was pointed out. But you’ll be able to write useful programs long before getting through all those topics above.
Also, a lot of people have given some really great sources for learning. I didn’t spend any time on this because I was trying to get an idea of how high you were aiming with this first. A lot of people on the internet are quick to point out that you can learn all this stuff online for free without going to school. While this is true (and fantastic) that doesn’t imply that doing it on your own is a good idea if your plan is to go pro. Even if you did want to go to school, all the online stuff is still available to help enhance your experience and accelerate you.
For example, here is a talk by Scott Young who completed the MiT CompSci degree curriculum on his own in one year:
There is a actually a huge movement out there with players like MiT OCW, EDx, Khan Academy, and many many more once you start digging.