locked
secure string functions (strcpy_s, strncpy_s) RRS feed

  • Question

  • Hi All,

    I am facing an issue related to _s string functions. Consider the following example.

    char szSrc[5] = {"Test"};

    char szDest [100] = {0};

     

    strcpy_s(szDest, sizeof(szDest) - 1, szSrc);

    This function copies the string "Test" to szDest along with NULL and 94 chars which follow Test<NULL> .

    In a prgrammer  perspective, this seems to be doing a memcpy for sizeof(szDest) - 1 bytes.

    Any comments?

    Friday, October 8, 2010 1:54 PM