strncpyBuffer method

CString strncpyBuffer(
  1. CString dest,
  2. CString src,
  3. int n
)

Copies up to n characters from the string pointed to, by src to dest.

Implementation

CString strncpyBuffer(CString dest, CString src, int n) {
  int i = 0;
  while (i < n && src[i] != 0) {
    dest[i] = src[i];
    i++;
  }
  while (i < n) {
    dest[i] = 0;
    i++;
  }
  return dest;
}