You have a few options
1. You can use the C standard library function rand(). It returns a value between 0 and RAND_MAX (some platform-specific big integer number), inclusive, as long as you remembered to seed it with srand() earlier.
To shrink the 0..RAND_MAX inclusive range to 1..8 inclusive, you again have options
1a if you do not mind degrading the uniformity of your distribution in favor of simple code, you can use modulus to shrink that range.
srand(seed);
...
int value = 1 + rand() % 8
test: https://ideone.com/SY6AZ
2a If you need slightly more uniform distribution 1..8, use floating-point division to shrink that range
srand(seed);
...
int value = 1 + rand() / (RAND_MAX+1.0) * 8;
test: https://ideone.com/vqggI
2. If your compiler is reasonably new (after 2005 or whenever it implemented TR1. Visual Studio 2010 and gcc 4.4 definitely work) or if your compiler is old but don't mind using the boost library, you can use the C++ standard library facilities instead. There you have a wide variety of random number generators and random number distributions to choose from.
mt19937 eng(seed); // Mersenne twister RNG
uniform_int_distribution<> dis(1, 8);
...
int value = dis(eng);
test: https://ideone.com/GLW8g