- Joined
- Jul 18, 2002
Alright, what im trying to get this to do is get a random number, then make the variable = that number. Is the best way to go at it the way I am? Or is there something else I could do? I appreciate any help.
code -
#include <iostream.h>
#include <time.h>
#include <stdlib.h>
int test;
int *p[] = {
int a = 1,
int a = 4,
int a = 8,
int a = 10,
int a = 13
};
main()
{
srand( ( NULL) );
test = rand() % 5;
cout << p[test];
return 0;
}
code -
#include <iostream.h>
#include <time.h>
#include <stdlib.h>
int test;
int *p[] = {
int a = 1,
int a = 4,
int a = 8,
int a = 10,
int a = 13
};
main()
{
srand( ( NULL) );
test = rand() % 5;
cout << p[test];
return 0;
}