how to generate a code like this

Newbie Member
6Nov2011,19:37   #1
atoivan's Avatar
i am writing a database program and i want to generate item codes so that all the item will be identified by this code.

the items are in categories examples (soft-drinks,wines beers ....etc )

i want to crate a function the will generate this codes for me. example a category (Array) is wines all the item codes in Wine in the Array Wine should begin with the word 'W' if it is Beers all the items codes in the Array Beer must begin with' B'.

thank u
Mentor
7Nov2011,20:00   #2
xpi0t0s's Avatar
Code:
char generate_code(char *category)
{
  return category[0];
}