• C++ Console Application Ideas
    20 replies, posted
Since I'm great enough at C++ to create console applications that actually don't suck, and yet I'm dumb enough to barely comprehend Windows programming, can anyone give me ideas for a console application that I should make?
- A maze generator. - Tic Tac Toe. - ASCII stuff. - Chat server/client. - IRC bot/client.
Write a shell
screen printer.
Roguelike
Make a text-based-Counter-Strike D:
You could try your hand at SFML and create a basic game. If you go through the tutorials on their site (don't just download the examples, actually type out the code yourself) you should learn enough to make a tic-tac-toe game.
Do [url]http://projecteuler.net[/url] problems
Slightly offtopic, but I did not want to start a new thread. I just looked at the "projecteuler" link that gilly posted and I had a go at problem 1. And for some reason my code is outputting the numbers that don't work instead of the ones that work. It is probably really simple and I am probably going to feel like an idiot after finding out what is wrong, but here is the code: [code] int counter = 0; while(counter < 10) { if((counter % 3) || (counter % 5) == 1) { cout << counter << "\n"; } counter++; } [/code] The output is: 0 1 2 4 5 7 8 I would be grateful if anyone could tell me what is wrong.
[QUOTE=xxxkiller;19669286]Slightly offtopic, but I did not want to start a new thread. I just looked at the "projecteuler" link that gilly posted and I had a go at problem 1. And for some reason my code is outputting the numbers that don't work instead of the ones that work. It is probably really simple and I am probably going to feel like an idiot after finding out what is wrong, but here is the code: [code] int counter = 0; while(counter < 10) { if((counter % 3) || (counter % 5) == 1) { cout << counter << "\n"; } counter++; } [/code] The output is: 0 1 2 4 5 7 8 I would be grateful if anyone could tell me what is wrong.[/QUOTE] You can't check both conditions with || like that, you need to do if (something == blah || someElse == blah)
Aha :D It worked, thanks.
[QUOTE=nullsquared;19669425]You can't check both conditions with || like that, you need to do if (something == blah || someElse == blah)[/QUOTE] That's one thing that always pisses me off about C++ but I have to live with. Is there any technical reason this isn't allowed in C++? Because it would really make a lot of if statements out there shorther...
It's more logical.
[QUOTE=gilly_54;19680215]That's one thing that always pisses me off about C++ but I have to live with. Is there any technical reason this isn't allowed in C++? Because it would really make a lot of if statements out there shorther...[/QUOTE] [cpp] #define either(x,a,b) (x == a || x == b) int foo = 1; if either(foo, 1, 2) { // true } [/cpp]
Or this: [cpp]#include <cstddef> //note: only works for stack-allocated arrays; use std::vector otherwise, pass a count-variable or use boost::array/C++0x std::array template<typename T> bool either(const T vars[], const T value){ const std::size_t count = sizeof(vars)/sizeof(T); for(std::size_t i = 0; i < count; ++i) if(vars[i] == value) return true; return false; }[/cpp] The C++0x/Boost-way: [cpp]#include <cstddef> #include <array> //boost/array.hpp for Boost //boost::array for Boost template<typename T, std::size_t Size> bool either(const std::array<T, Size> &vars, const T &value){ for(std::size_t i = 0; i < Size; ++i) if(vars[i] == value) return true; return false; }[/cpp]
[QUOTE=gilly_54;19680215]Is there any technical reason this isn't allowed in C++?[/QUOTE] Yeah, it doesn't make sense. == tells you if 2 things are the same. Exactly 2 things, no more, no less. || tells you if either of 2 conditions is true. Either of exactly 2 conditions, no more, no less. if (a || b == c) says "if either the condition 'a' or the condition 'b == c' is true, then execute the body of this if statement" Yes, numbers in C++ can be implicitly converted into booleans - anything non-zero is true, 0 is false.
[QUOTE=Agent766;19657082]Make a text-based-Counter-Strike D:[/QUOTE] Reminds me of this thing I found a while back: [URL="http://xkcd.com/91/"]http://xkcd.com/91/ - Cartoon: Text-based Counter-Strike[/URL]
I'm pretty sure that's where I got that from. I had the idea stuck in my head for a long time.
[QUOTE=gilly_54;19680215]That's one thing that always pisses me off about C++ but I have to live with. Is there any technical reason this isn't allowed in C++? Because it would really make a lot of if statements out there shorther...[/QUOTE] Make it a function.
[IMG]http://imgkk.com/i/MDS1Z1.png[/IMG] I tried to make a tetris one but It was to complicated
*CLIP--that was stupid*
Sorry, you need to Log In to post a reply to this thread.