1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how to generate a code like this

Discussion in 'C' started by atoivan, Nov 6, 2011.

  1. atoivan

    atoivan New Member

    Joined:
    Nov 6, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    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
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Code:
    char generate_code(char *category)
    {
      return category[0];
    }
    
     

Share This Page