rand function

This is a discussion on rand function within the C Programming forums, part of the General Programming Boards category; hey i am doing a battleship program and i am just wondering how would you be able to change the ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    3

    Cool rand function

    hey i am doing a battleship program and i am just wondering how would you be able to change the ships position after every game??

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    srand ( time ( NULL ) );

    Then use rand to set the position. Be sure to include time.h.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

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