Reputation: 135
Is it possible to include variables through using %c
and such when you have strings saved into the array?
char *MainMenuNames[] = { "%c - Move Left", "%c - Move Right","%c - Move Up","%c - Move Down","%c - Back","%c - Confirm","%c - Show Stats","%c - Show Inventory","%c - Show Legend","%c - Show Controls"};
When I have something like this, is it possible to put something into the %c
?
Upvotes: 1
Views: 472
Reputation: 780994
You can use the array element as a parameter to formatting functions like printf()
char *commands = "lrudbcsiln";
for (int i; i < strlen(commands); i++) {
printf(MainMenuNames[i], commands[i]);
putchar('\n');
}
Upvotes: 2