StrcopyA, StropyW

int StrcopyA(char *dest,int n,const char *src);
int StrcopyW(wchar_t *dest,int n,const wchar_t *src);

Replaces unsafe calls to strcpy()/wcscpy(). Copies at most n-1 characters from the null-terminated ASCII (StrcopyA) or UNICODE (StrcopyW) string src to dest and assures that dest is null-terminated. Returns number of actually copied characters, not including the terminal null.


Parameters:

dest
(out) Pointer to the output string, at least n characters long
n
(in) Length of dest, characters
src
(in) Pointer to the input string


Return values:

Number of the characters copied from src to dest, or 0 on error


Example:

#define VERSION        L"2.00.00"      // Plugin version

int Getpluginversion(wchar *s,int nmax) {
  int n;
  n=StrcopyW(s,nmax,L"Plugin v");
  n+=StrcopyW(s+n,nmax-n,VERSION);
  return n;
}



See also:
SetcaseA(), SetcaseW(), StrcmpW(), StrcopycaseA(), StrcopycaseW(), StrlenA(), StrlenW(), StrnstrA(), StrnstrW()