Thread: sprintf(len+id ?

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    24

    sprintf(len+id ?

    Hi,

    I'm trying to translate some C code to java and trying to understand some code so I could write it. Now I'm not a C expert, so don't laugh at me

    I'm trying to figure out what the line below does:

    Code:
    sprintf(id + len,"%08x",(uint32_t)(timems & 0xffffffff));
    Where 'id' is u_char and 'len' is integer. Does he copy the resulting char array to id[len] or something ?

  2. #2
    Registered User
    Join Date
    May 2007
    Posts
    147
    You basically got the idea.

    id is the output string. It seems the author wanted that output to start at the 'len'th character in that array.

  3. #3
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Yes, he wants to start at id[len], such as

    'id' might be: "abcdefghijk\0"
    And 'len' might be 4, so he wants to start at 'e'. Of course abcde... have been placed there as a visual aid.

Popular pages Recent additions subscribe to a feed