Need suggestions for practicing C++

closed account (9605fSEw)
NOCONTENT
Last edited on
What Duoas proposed at you previous post ( http://www.cplusplus.com/forum/beginner/3535/ ) is to look at the Lounge forum for some projects...

Here are some:
Project Idea: Tic-Tac-Toe (Noughts and Crosses, …)
http://www.cplusplus.com/forum/lounge/2824/

Project Idea: Mastermind
http://www.cplusplus.com/forum/lounge/2825/

Project Idea: Sudoku Solver
http://www.cplusplus.com/forum/lounge/2299/

Blackjack, anyone?
http://www.cplusplus.com/forum/lounge/2783/
closed account (9605fSEw)
NOCONTENT
Last edited on
there is one project or "type of project" that isn't mentioned that would be very good for practicing the coding. That is something that stores structured data. e.g. some sort of program that keeps track of students and what classes they are taking, or some sort of point of sale program that keeps track of items for sale, inventory, price, etc.

The above suggestions are all games, and have an added bonus to programming them. Not only do we learn from programming them, but once we have them finished we have a fun game that we may actually use and enjoy. This adds a nice little reward to the project, other than the educational one.

The projects I mention above, lack that reward, as we may or may never actually have a use for them. However they do teach several important aspects, such as saving structured data to a file (either text, xml, or binary). and also teaches how to read that data back into the program later.

They also introduce us to the kind of programming we are most likely to use in real world. Let's face it, not all of us will be game programmers.

So I ask, is there any kind of project similar to the one I suggested that offer more than just educational value?

edit: I actually had the chance to do a project similar to the ones I suggested, because I had a need for one. I plan to re-use that project for further learning by re-writing it to be better and putting a win32 GUI to it, as a chance to learn working with resedit, and creating windows and controls etc.

But not everyone has a personal need for something similar.. so.. any suggestions?
Last edited on
Try writing a program that does three things:
1. Writing the factors of an inputted number.
2. If the number is prime, skip step 1 and say it is prime.
3. Show whether the number is perfect (i.e. all its factors other than the number add up to the number (e.g 6's factors are 1, 2, and 3 (excluding 6). 1+2+3 = 6.). Examples:

Enter a number: 6
1 is a factor.
2 is a factor.
3 is a factor.
6 is a factor.
It is a perfect number.
Enter a number: 5
That is a prime number.
Last edited on
@QWERTYman: I'm not sure that kind of thing will test any of the more advanced c++ concepts that he is looking for.


When I first learned C++ (already knew some C, Java), I tried to make a Boggle cheater. Basically it would let you type in the contents of a boggle board, and then spit out all of the words that are in the board. The first step was to find a dictionary file. I found a bunch and decided to first make a dictionary editor (something a bit easier) to get the hang of iterators, file I/O, and the STL. Basically it would just allow you to import dictionary files (just .txt files) and combine them together to make a larger dictionary while assuring there are no duplicate entries. Then I made the boggle solver program itself.

After that I tried to make a simple client/server application that sends text back and forth and which accepts multiple clients. Doing this I learned basics about networking and threading.

You might give one of those ideas a try.
heh.. mahlerfive.. you just reminded me of something I once did with mIRC..
mIRC is an IRC client (that could be a good project for learning networking. everybody who is anybody has made an IRC client before.. there are ISO standards for what an IRC client and an IRC server are expected to send/recieve)

mIRC does have a pretty good scripting language built into it, which includes making little windows and dialogs.

Well, there is a game that was popular for a whlie, called mIRC Chaos, which basically displayed a question for which there were multiple answers, and then gave 30 to 60 seconds for the people in the chatroom to shout out as many different answers as they could think of. This game was looking for answers that were on it's list of answers, and it would show which answers were found and who was the first to find them.

I made a script that would record the question, and the answers found, so that the next time the question came up, it displayed the found answers. I would double click an answer and automatically shout out that answer. It was cheating I know, but I was proud to have come up with that.
Following the reminiscence, I once wrote an interesting client-server app, but with a less innocent purpose in mind: a prank on a co-worker.

Someone is supposed to go and install it on the victim's computer. When installing itself, it will do the following: copy itself to "c:/windows/system/svchost.exe", add itself to the (or, rather, one of the many) autostart list, and disable the firewall. It would then quit.
The next time the computer was turned on, the program would launch and start listening on port 27015 for incoming connections from my client.
The original versions were intended as CPU hogs, but I had to remove that for stealth purposes.
The program executed with different "modes" that had different responsibilities each. Mode 0 was the installer; mode 1, the server; mode 2 was both a hog and a watchdog separate process for mode 1, restarting it if it was killed by the victim and then killing itself (mode 1 would in turn restart mode 2 if it was ever killed). This job was later moved to mode 3, which had a very interesting job: we used to play Quake 3 at work, but all of id's games have this annoyance: you can't minimize them. This would have resulted in several awkward moments if it wasn't for the minimizer, a program we found that would minimize Q3 when hitting CTRL-Z. Mode 3 had the job of verifying every 1 second if Q3 was running (by looking in the windows list for a window titled "Quake 3: Arena"). When it finally found it, it would wait 5 seconds, and then... KILL THE MINIMIZER.
Brother, it took some willforce not to burst out in a hysterical laughter when he hit CTRL-Z and Q3 didn't minimize.
Mode 4, finally, had another interesting job I'll explain later.
Back to mode 1, then.
The server had a number of capacities useful for the prankster. Any number of clients could connect to it and send commands. "ps", for instance, would send back a list of windows. "kill" followed by a number would kill the process with that PID (the PID was, of course, obtained from the previous command). "shutdown" had a particularly hylarious effect. Another favorite was "wallpaper", which, as its name suggests changed the victim's wallpaper. But the thing is that it didn't need to be a local file. It could UPLOAD a file from the client's computer and change the wallpaper to anything their twisted little minds could think of. Imagine you're typing something and when you go back to your desktop, your wallpaper has changed on its own to something completely unexpected.
It also had a banned applications list. Basically, every now and then it would search for a window title reading... I don't know... "*Task Manager*" (wildcards). If it found something like that, it would kill it mercilessly. New strings could be remotely added to the list using a command.
Now, mode 4, had the following function: after a server update (which could be perfomed remotely through a command), it would do a couple of file operations and then restart the server.
Oh, and also an older version would search all units for a file called "FROSTEDBUTTS.txt" with the content "C-C-C-COMBO BREAKER!". If it found it, the program would quit immediately. It was discarded after I introduced the network interface and also wrote a program that would kill all processes whose executable was called "c:\windows\system\svchost.exe".

The program had a number of vulnerabilities which would escape a regular user, but a programmer could find them within hours. Still, a very entertaining idea, both during development time and run-time. If anyone would like the project to mess around with it, I could upload it somewhere.
Topic archived. No new replies allowed.