Battleships

This is a discussion on Battleships within the Game Programming forums, part of the General Programming Boards category; <split from http://cboard.cprogramming.com/showthread.php?t=7988; thread bumps, particularly from six years ago, are best avoided ~ken fitlike> hey guys i need some ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    1

    battleship

    <split from c++ battleship game thread bumps, particularly from six years ago, are best avoided ~ken fitlike>

    hey guys i need some help with a battleship program, im not too sure how to do it..
    basically it needs to have a 15 by 15 grid,
    i dont expect any1 to do a full code for me but i just need some help gting started..
    Last edited by sucram; 02-03-2008 at 09:38 PM.

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,823
    This code cannot compile if a function does not specify return type.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    May I plug my little battleship game? You may get some ideas from it. The way I input locations is I assume that it's input the right way, use atoi (hey, I wrote it a while ago) and check the resulting data. If they type in something about a teapot then they get to try again until they get it.

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,823
    Well, I'm certainly not going to evaluate all the code, but an interesting (or dangerous thing) is that you use scanf incorrectly to read strings. Read my signature from the proper way (or use fgets!).
    And rather than atoi, it's preferable to use strtol. But it's optional.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    Quote Originally Posted by Elysia View Post
    Well, I'm certainly not going to evaluate all the code, but an interesting (or dangerous thing) is that you use scanf incorrectly to read strings. Read my signature from the proper way (or use fgets!).
    And rather than atoi, it's preferable to use strtol. But it's optional.
    Heh, I never knew that. But then again I'm sure that a decent programmer could dissect all my code and find all sorts of worst practices that i use. I've got a lot to learn, but I'm all self taught.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Battleship
    By Unregistered in forum Game Programming
    Replies: 11
    Last Post: 11-29-2001, 03:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21