Condividi tramite


_StrCpy( ) API Library Routine

Copies a null-terminated string from src to dest.

void _StrCpy(char FAR *dest, char FAR *src)
char FAR *dest;            /* Destination location. */
char FAR *src;               /* Source location. */

Remarks

_StrCpy( ) doesn't support overlapping moves. Overlapping moves are required when src and dest have some bytes in common. If overlapping moves are required, use _MemMove( ).

For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.

Example

The following example is passed a Visual FoxPro array of type Character. It then replaces the second element using _Store( ).

Before calling MYFUNC( ), the Visual FoxPro example code creates an array and initializes it to type Character. MYFUNC( ) passes this array by reference.

Visual FoxPro Code

SET LIBRARY TO STRCPY  
? STRCPY("Hello", " world")   && returns "Hello world"

C Code

#include <pro_ext.h>

FAR Example(ParamBlk FAR *parm)
{
#define p0 (parm->p[0].val)
#define p1 (parm->p[1].val)

   if (!_SetHandSize(p0.ev_handle, p0.ev_length + p1.ev_length))
      _Error(182); // "Insufficient memory"
   _HLock(p0.ev_handle);
   _HLock(p1.ev_handle);
   ((char FAR *) _HandToPtr(p1.ev_handle))[p1.ev_length] = '\0';

   _StrCpy((char FAR *) _HandToPtr(p0.ev_handle) + p0.ev_length,
      _HandToPtr(p1.ev_handle));

   _RetChar(_HandToPtr(p0.ev_handle));
   _HUnLock(p0.ev_handle);
   _HUnLock(p1.ev_handle);
}
FoxInfo myFoxInfo[] = {
   {"STRCPY", (FPFI) Example, 2, "C,C"},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also

_StrCmp( ) API Library Routine | _StrLen( ) API Library Routine | String Manipulation Routines | _PutStr( ) API Library Routine | _WPutStr( ) API Library Routine