I have a struct solar_system, and a struct planet. I want to create solar_system test_system, which should then contain planet planets, then assign a string to test_system.planets[1 through max_planets].name, and then view the name of each planet.
Heres the relevant code
The issue comes up when I try to access test_system.planets[n].name
void generate_random_name(char* name)
int n = rand()%3+1;
case 1: strcpy(name,"one");break;
case 2: strcpy(name,"two");break;
case 3: strcpy(name,"three");break;
case 4: strcpy(name,"four");break;
default: mvprintw(0,0,"INVALID NAME GENERATION");break;
For whatever reason instead of printing "one" or "two" etc it prints "^A" "^B" and so on. If I add a line within solar_system() to print planets[n].name as it is generated everything is fine; it prints "one" and "two" and so on as would be expected. The issue only seems to come up when I try to access the name from outside of solar_system()
I hope I explained the situation well enough, if more information is needed I'd be happy to provide it. I am still sort of a newbie so the code is probably not the prettiest but any help with this particular issue would be appreciated.