I've been searching for an answer to this for quite some time now, to no avail. So, as my final effort I will ask the public.
string* random_ai_car() {
srand((unsigned)time(NULL));
int random = rand() % 6 + 1;
string ai_color[6] { "Pink","blue","purple","black","grey","silver"};
string *get_car;
get_car = &ai_color[random];
return get_car;}
I know that I probably do not need the pointers. It was kind of silly to try and use them for this function. How I want this program to function is that it will generate a random car color and then I could use it in my cout<< in my main method. Every time I try to use it in main() it just either gives me nothing at all or, in cout<< it gives me about 6 digits of numbers. My question is, am I returning the wrong value to actually get an output? or am I not using the function with the string properly?
update:
So, I diced into a bit more of what was being said about my poor beginner skills, so I researched different things about how to call within the function. I still don't quite understand how that works exactly. Can someone provide my with a link to learn more about why and how you should properly call a function and or return a function? I did happen to fix the problem, not quite how I wanted to do it though
string* random_ai_car() {
int random = rand() % 5;
string ai_color[6] { "Pink","blue","purple","black","grey","silver"};
string *get_car;
get_car = new string;
*get_car = ai_color[random];
return get_car;