Need program tested on other computers

This is the first program that I have created that might be of any "use". It is a simple battleship game that I think I have fixed all the bugs in but I'm not sure. I would simply enjoy for someone to test it and give back any positive feedback such as advice and/or something that needs to be fixed.

Here is the link:
http://dl.dropbox.com/u/67507954/BattleShip.exe

Thanks for playing!
I can't execute that.
I think it would be much better if you distribute the source code.
Overall, not bad!

You can place ships on top of each other. Is that intentional?
Never mind, you can't place them when they're overlapping.

Oh, and are you using a huge amount of system() calls?
(Every time I enter a choice, the game executes cmd.exe. That's how I can tell you're using a lot of system("cls") and system("pause").)

It's kinda tedious at the beginning (if you choose to place your own ships) to have to type the letter (to move the ships) and then press enter.
It'd be a lot more convenient if you just had to press the letter.
(yes, it's possible to make it like this -- I can teach you how if you want :-) )

I shall give you a challenge: instead of clearing the screen and redrawing everything every time the field changes, only redraw what needs to be redrawn.
Think you can do it? :)
You mean there's an alternative to system("CLS")??? I know there's an alternative to system("pause"), but I figured if I couldn't avoid using system functions, I may as well use pause.

I ALSO didn't know that I could make it to where you didn't have to press enter in order to take the user's input. If that's true, could I just use the arrow keys instead of u, d, l, r?

And a not-so C++ related question... is there any way to have it where when someone goes to download the program, it doesn't tell them it is a virus? It is so difficult to get people to try out the program because who wants to download and run some program if they don't know what it does? Gmail (and Facebook) won't even let me send a zip file containing my program because Gmail doesn't trust it.

and LASTLY, is there a way to send an individual user my source code? I don't want it just out there for anyone to claim as their own.
You mean there's an alternative to system("CLS")???

http://www.cplusplus.com/articles/4z18T05o/
here is the (embarrasing) source code:

http://dl.dropbox.com/u/67507954/BattleShip.cpp

Please keep in mind that I am VERY new to C++
Last edited on
If you don't want people to steal your source code, put a license on it. If you want anyone to be able to read, use, modify and re-distribute your program (but NOT claim it as their own) you can use a free/open-source software (FOSS) license like the MIT license or GNU GPL.
closed account (S6k9GNh0)
Chrisname, people cannot take your code if it does not have a license. If the code does not have a license, it's at the authors discretion what people can do with it and permission must be given to those who use it. Same thing with art and others. Just because people post something up doesn't mean you can use it or distribute it. A website such as this one will often contain a license agreement where everything you post on the forums is under a certain set of rules and you must agree to this.

This forum specifically has you agree to this: "Any content you provide is to be free of charge and royalties for cplusplus.com and with permission to be published, moved and copied in this site and in accordance with the copyright notices at the bottom of our pages."
Last edited on
Regardless, my source code is already posted and the only value it has is sentimental.
@computerquip,
That's true, actually, any content you create is implicitly "all rights reserved" (at least, in the UK and US it is). However, I think putting a license on it is probably safer. It'd be hard to prove you were the author if there's no version that says "this is mine".
Having a license in your source is a relic, but a good one.

International law (to which all civilized, and many uncivilized, countries are signed) does not require it. However, it does better protect you against dishonest parties who claim ignorance to your copyright (or "innocent infringement") when you take them to court.

Edit: a link I found:
http://www.law.cornell.edu/uscode/text/17/401
Last edited on
@OP: Unfortunatly the "system()" calls are probably why you are getting flagged as a virus.
good to know. Getting rid of all the pauses is a piece of cake, but Idk about system ("CLS");
Since you're already using a bunch of Windows-specific functions, might as well use some more:
http://pastebin.com/64Bw6w1M
(felt it was a bit lengthy, so I didn't copy/paste directly into this post)

That's one way to get arrow keys as input....

Also:
1255
1256
1257
1258
1259
1260
1261
if (x == 0)
    letter = 'A';
if (x == 1)
    letter = 'B';
if (x == 2)
    letter = 'C';
// etc. 

can be simplified to just
letter = x + 'A';

And
759
760
761
762
763
764
765
766
767
768
769
770
if (letter == '0')
    return 0;
if (letter == '1')
    return 1;
if (letter == '2')
    return 2;
// etc.
if (letter == 'A' || letter == 'a')
    return -1;
if (letter == 'B' || letter == 'b')
    return -2;
// etc. 

can also be simplified to
759
760
761
762
if (isdigit(letter))
    return (letter - '0');
else if (isalpha(letter))
    return -(toupper(letter) - 'A' + 1);

(someone correct me if I messed up somewhere)
The assumption that 'A' to 'Z' and 'a' to 'z' are contiguous runs in the character set isn't one you can make, according to the standard. For '0' to '9' it's perfectly safe.

For a windows-specific program like this it probably isn't terribly important, though.
The assumption that 'A' to 'Z' and 'a' to 'z' are contiguous runs in the character set isn't one you can make, according to the standard. For '0' to '9' it's perfectly safe.


Why not? As long as the system uses either the ASCII or UTF-8 character encodings (which virtually all do), then 'A' to 'Z' and 'a' to 'z' will be contiguous runs, am I wrong? :/

-Albatross
Topic archived. No new replies allowed.