cpybuf
Copy one buffer area to another regardless of any null characters.
Short Name
cpybuf()
Type
Utility function
Declaration
void cpybuf(pTEXT destination, pTEXT source, UINT length)
Description
cpybuf() copies length bytes from source to destination.
It does not stop when it sees a null character. You can copy strings or structures with this.
We strongly suggest using cpybuf() instead of strcpy(), for the following reasons:
Example
FILNO keyno;
TEXT target[24],idxval[23];
LONG recbyt;
scanf("%23s",target);
recbyt = GetGTEKey(keyno,target,idxval);
while (recbyt) {
printf("\nIndex entry = %23s ", idxval);
printf("\nRecord # = %ld, recbyt);
cpybuf(target,idxval,23);
recbyt = GetGTKey(keyno,target,idxval);
}
Limitations
cpybuf() does not check to see if the buffer at destination is large enough to hold the data being moved.
See also
FairCom DB also includes cpybig(), which provides the same functionality as cpybuf(), and works for very large buffers, even on machines with segmented memory models. The length parameter is declared as VRLEN instead of UINT, which provides for larger buffers. Also see strcpy().