Two obvious solutions:
1. Using a table to convert from "number to name":
Code:
struct {
int cake;
char *name;
} cakeToString[] =
{
{ 225, cake225 },
{ 261, cake261 },
...
{ 0, NULL }
};
Then walk through the list and find the cake number, and use the name.
2. Use a switch statement:
Code:
char *getCakeName(int cake)
{
switch(cake) {
case 225: return cake225;
case 261: return cake 261;
...
default: return "Invalid Cake";
}
}
There are further solutions, but those are the first two that comes to mind. Which you prefer depends quite a bit on what the rest of the code is supposed to do, and perhaps you actually need some more functionality to be performed.
--
Mats