how to generate a code like this

atoivan's Avatar, Join Date: Nov 2011
Newbie Member
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
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Code:
char generate_code(char *category)
{
  return category[0];
}