hey GD, I have some code I'm trying to get working. the goal is to take one random string from 2 different arrays and print the result. Based on the tests I've run I'm having trouble getting a string and not just a set of numbers or unknown characters. Here is a modified (for clarity) example of what I have now.
void NameGen(WINDOW *win)
{
srand(time(NULL));
int lstn = rand() % 5;
int fstn = rand() % 5;
char *surname[5] = { "Carter", "Nagano", "Johnson", "Boustrup", "Smith"};
char *first_name[5] = {"Jeremy", "Chris", "Aya", "Corey", "Eiden"};
wprintw(win, "%s, %s", surname[lstn], first_name[fstn]);
}
EDIT: Fixed, the above example is actually, infact, exactly how one would go about doing this. By seeding and setting rand() to the same value as the array you essentially leave it up to the program to spit the results back out at you. The above sample also works with single characters and numbers. there is plenty of room for optimization, this function is barebones. I suggest having something offset a recalculation if you plan on calling something like this more than once so that you don't generate different names every time (unless that's what you desire).