strcpy_s - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.


dbrandtdbrandt Posts: 43Member
Basically I have 2 variables, szRecvBuff and param. I want param's value to be the same as szRecvBuff's value, except the first two letters in szRecvBuff are NOT in param. I set up this code:

char szRecvBuff[1024];
char param[1024];
for (int z = 2; z < (strlen(szRecvBuff)); z++)
strcpy_s(param[z], szRecvBuff[z]);

I get this error:
error C2660: 'strcpy_s' : function does not take 2 arguments

Of course strcpy_s takes 2 arguments, so what the hell's the problem? I'm using VC++ 2005 btw.


  • LundinLundin Posts: 3,711Member
    It expects pointers.

    strcpy_s (&param[z], &szRecvBuff[z]);
  • katmankatman Posts: 24Member
    I'm wonder why you are using strcpy in the loop? If I understand your goal to skip the 1st 2 chars in szRecvBuff, the following loop would do it:

    char szRecvBuff[1024];
    char param[1024];
    for (int z=2; z < (strlen(szRecvBuff)); z++)
    { param[z-2] = szRecvBuff[z]; }

    However, consider what the following code does:

    char szRecvBuff[1024];
    char param[1024];
    strcpy(&param[0], &szRecvBuff[2]);

    (szRecvBuff is Null terminated and at least 2 characters long, which you could check with an if (strlen...))
Sign In or Register to comment.