This is a bit longish so hope you have time to read
When I started studying programming initially, I mean programming generally not just C/C++, I found a perfect way that fits for me and my little male tunnel brains. That was 36 years ago, I was 12 years old.
I started copying the games I was playing on my current computer at that time. Okay, the programming language was initially Basic. But.
My point is that the best way to learn new programming language for me is to pick up a project and just start implementing it. You will bump into big obstackles but you will solve them as you go forward with your project. Whenever you face some issue you do not know to do, study some, find information and you will learn.
Do you prefer to watch videos or learn by reading? I prefer the reading method. But that comes from the fact that when I was learning programming, the books were the only source of information, there was no Internet
. However, I have *never* read a programming book from cover to cover before starting to do my task. I read the basics and start implementing as soon as I am confident enough to be able to do something.
When I want to learn a new programming language, I will always pick up a project I want to do. Then start tackling it and the challenges, step by step.
I can give you one good practice I've been using myself in the past many times in different environments. I used this exact task 3 months ago when I started (FINALLY!) learning Python.
Task: Implement a console program which can show a binary file in ASCII hexadecimal representation.
The program shall take an argument telling how many bytes per row are displayed and another argument for how many lines are displayed out. The program always reads from the beginning of the file, for this excersise.
To start the application you use following syntax:
hextype.exe -i <filename> [-l <linecount>] [-b <bytes_per_row>]
Where
-i defines the input file, binary or text, whatever
-l defines how many lines are displayed. Optional. if omitted displays the whole file
-b defines how many bytes per row are displayed. Optional, if omitted displays 16 bytes per row.
Desired output format:
OFFSET (hex, 32-bit) : Bytes in ASCII (hex) : ASCII characters for the bytes, unprintable as '.'
e.g. for command "
hextype.exe -i myfile.bin -l 3":
Code: Select all
00000000 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f : ................
00000010 : 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f : !"#$%&'()*+,-./
00000020 : 30 31 32 41 42 43 61 62 63 64 65 66 67 68 69 6a : 012ABCabcdefghij
For reference,
ASCII table can be found here., There are many alternatives.
Challenges to conquer:
- How to get program arguments
- How to open (and close) a file from filesystem
- How to read the file in binary format
- How to process the read file data
- How to convert the bytes to ASCII representation
- How to output the ASCII bytes to console output
- How to format the output as required by the task
For the binary -> ASCII conversion
here's an "advanced" example I made few weeks ago. It uses templates and streams for conversion between binary<->ASCII bytes, words and longs.
This task makes you to dive into many fundamental concepts in any programming language. For example:
- How to get program arguments
- Control and program structures
- Input/output, file and console
Always do incrementally, do one task and test it. Then expand. No need to tackle all the challenges at once
You would be overwhelmed very easily.
Here are some pointers you could start learning C++ from:
Written
Here's a written C++ tutorial which goes step by step:
C++ Tutorial @ w3schools.
Another nice tutorial from basics to advanced:
C++ Language @ cplusplus.com
Another good tutorial here:
Learn C++, simply easy learning @ tutorialspoint.com
Here's a collaborative collection of tutorials and information on C and C++:
Coding Den Wiki
FAQ in question/answer format:
Written C++ FAQ for newbies and veterans
Once you get to actually doing something you will eventually bump into this site for C++ reference up to C++20 standards:
C++ Reference
That one is quite technical, friendlier version
is here @ cplusplus.com
Videos
A friend of mine has many good videos on C++ programming here from basics to advanced concepts:
One Lone Coder (javidx9)
If you type a YouTube search for example "C++ tutorial for beginners" you will find tens if not hundreds of channels which teach you C++, step by steam.
Finally, if you are interested
My GitHub has some basics and some advanced stuff. And if anything else does not help use Google. Just type a question and you'll find many solutions, for example "C++ output text to console" will surely give you answers
Good luck! It's fun!
Feel free to ask any questions if you so want, I'll try to answer. <3