Structures and pointers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hemant sail
    New Member
    • Nov 2007
    • 2

    #1

    Structures and pointers

    Hi
    I would like to know how we can copy 1 structure into another without the addesses
    that is
    in a function I am passing a structure pointer
    BOOL match_key_to_re c(char *pkey, char *prec)
    {

    }
    where pkey is
    PUTAWAYKEY_S *pkey;

    Inside the function I am defining a structure variable
    PUTAWAYKEY_S lpkey

    and i am using the foll
    memcpy( lpkey.load_type , (*pkey).load_ty pe, 1 );
    memcpy( lpkey.sku, pkey->sku, L_SKU );
    memcpy( lpkey.company, pkey->company, L_COMPANY );
    memcpy( lpkey.season, pkey->season, L_SKU_SEASON_CO DE )

    where sku,load_type,c ompany and season are the structure fields
    Will this work I an getting the errorsin this statements

    Kindly provide your valuable ideas

    Hemant Sail
    INDIA
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Originally posted by hemant sail
    I am passing a structure pointer
    BOOL match_key_to_re c(char *pkey, char *prec)
    {

    }
    A char* is not a structure pointer. You say that pkey is a PUTAWAYKEY_S * so I would expect the function arguments to be:
    [code=c]
    BOOL match_key_to_re c(PUTAWAYKEY_S *pkey, PUTAWAYKEY_S *prec)
    {

    }
    [/code]

    what does your struct look like?

    Almost certainly memcpy() is not the way to go.

    Comment

    Working...