using an input variable within a variable name
Sorry if title is wrong im new to programming C and am stuck.
Iv asked the tutor today how to do this and she wasn't sure how :/ basicaly i want to use a user inputed number as part of the call to a char variable. So say user inputs 225 the program uses 225 as part of the variable name to get the infomation eg 225 added to cake makes cake225 which displays "Chocolate Eclair". Iv include some code to show what i mean.
Code:
#include <conio.h>
#include <stdio.h>
void getcake (int num);
char cake225[] = "Chocolate Eclair";
char cake261[] = "Vanilla Slice";
char cake262[] = "Custard Tart";
char cake265[] = "Strawberry Meringue";
char cake267[] = "Apple Turnover";
char cake271[] = "Iced Finger";
main()
{
int codenum;
clrscr();
printf("Please enter cake code ");
scanf ("%i", &codenum);
printf("you entered %s", cake+codenum); // <<Im unsure how the cake+codenum should be formatted.
getch();
return 0;
}
If user inputs 225 then codenum=225 - i want "cake+codenum" to tell the program that i want "cake225" but i keep getting the error "undefined symbol cake"