wierd compiler error in bloodshed
EDIT: Sorry to edit so soon, but I went back after taking a break and solved 3 more of the original 7 errors that stumped me. Now I got 4 left, and I am stumped again!
Im testing myself and building a DOS game.
Its a simple fight game, where the player contorls a character and the computer the other (using the simplest AI program ever :)). It's based on choosing a random number, then doing an action based on where the number is (<50, do this thing, >50 do another thing, etc).
Im getting errors, and I don't know why. I've included thesource code in my projec thats been bugging out, and the compile errores
Source Code in Question(same GetRand(int,int) as from the tuts on this site, worked fine until today):
Quote:
#include <iostream>
#include <stdlib.h>
#include <ctime> //code from cprogramming.com
int GetRand(int min, int max)
{
static int Init = 0;
int rc;
if (Init == 0)
{
/*
* As Init is static, it will remember it's value between
* function calls. We only want srand() run once, so this
* is a simple way to ensure that happens.
*/
srand(time(NULL));
Init = 1;
}
/*
* Formula:
* rand() % N <- To get a number between 0 - N-1
* Then add the result to min, giving you
* a random number between min - max.
*/
rc = (rand() % (max - min + 1) + min);
return (rc);
}
Compile Errors:
Quote:
GetRand.cpp: In function `int GetRand(int, int)':
GetRand.cpp:6: redefinition of `int GetRand(int, int)'
GetRand.cpp:6: `int GetRand(int, int)' previously defined here
GetRand.cpp:6: redefinition of `int GetRand(int, int)'
GetRand.cpp:6: `int GetRand(int, int)' previously defined here