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.


  • It expects pointers.

    strcpy_s (&param[z], &szRecvBuff[z]);
  • 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.

Howdy, Stranger!

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