Hey Thanks for helping me out here. I seem to have found this small bit of code thats been bugging me, sorry for the pun. Anyways on line 3 I can either use < <cstdlib> or <stdlib.h> . What is the difference and also what does the h stand for I believe it's header but not for sure on this one. Sorry if this has already been posted I couldn't find it. If it already has if you could link me to it that would be amazing. Thanks.
#include <iostream>
#include <math.h>
#include <cstdlib> // Or should I use this? ---> #include <stdlib.h>
#include <time.h>
int rand_0toN1(int i);
int main()
{
int n, i;
int r;
srand(time(0)); // set a seed for random-num
//generation
std::cout << "Enter number of dice to roll: ";
std::cin >> n;
for(i = 1; i <= n; i++)
{
r = rand_0toN1(6) + 1; //get number from 1 to 6;
std::cout << r << " "; //print out
}
return 0;
}
int rand_0toN1(int n)
{
return rand() % n;
}
What Computergeek01 said.
Like these: C------------------>C++
stdlib.h----------->cstlib
string.h----------->cstring
time.h------------->ctime
stdio.h------------>cstdio
etc.