I'm having trouble getting random numbers to generate. For some reason I'm getting huge, and some negative, numbers when I print the random numbers after the while loop. No idea what's going on so any help is greatly appreciated!
int genRan(int numHigh, int numLow){
int ranNum = rand() % (numHigh) + numLow;
return ranNum;
}
generateDungeon(){
int ranRow, ranCol, ranWidth, ranHeight;
for(int i = 0; i<5; i++){
bool check = false;
while(check == false){
int ranRow = genRan(18, 1);
int ranCol = genRan(77,1);
int ranWidth = genRan(8,3);
int ranHeight = genRan(7,2);
if((ranCol + ranWidth) <= 78 && (ranRow + ranHeight) <= 19){
check = true;
}
}
printf("%d\n", ranRow);
printf("%d\n", ranCol);
printf("%d\n", ranWidth);
printf("%d\n\n\n", ranHeight);
for(int x = ranCol; x<ranWidth + ranCol; x++){
for(int y = ranRow; y<ranHeight + ranRow; y++){
//dungeon[x][y] = '.';
}
//printf("%d ", x);
}
}
}
int main(){
srand(time(0));
generateDungeon();
//genRan();
return 0;
}