Compartir a través de


_MemFill( ) API Library Routine

Fills an area of memory starting at the location pointed to by ptr with length copies of the byte in character.

void _MemFill(void FAR *ptr, int character, unsigned int length)
void FAR *ptr;               /* Starting point for fill. */
int character;               /* Character for fill. */
unsigned int length;         /* How many bytes to fill. */

Example

The following example uses _MemFill( ) to duplicate the functionality of the Visual FoxPro function REPLICATE( ).

Visual FoxPro Code

SET LIBRARY TO MEMFILL 
x = xREPLICATE("x", 120)
? x
? LEN(x)

C Code

#include <pro_ext.h>

FAR Example(ParamBlk FAR *parm)
{
   char FAR *rep;
   char c = *(char *) _HandToPtr(parm->p[0].val.ev_handle);

   rep = _Alloca((int) parm->p[1].val.ev_long + 1);

   _MemFill(rep, c, (int) parm->p[1].val.ev_long);

  rep[parm->p[1].val.ev_long] = '\0';
   _RetChar(rep);
}
FoxInfo myFoxInfo[] = {
   {"XREPLICATE", (FPFI) Example, 2, "C,I"},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also

Concepts

API Library Routines A-Z

Reference

_MemCmp( ) API Library Routine

_MemMove( ) API Library Routine

_MemAvail( ) API Library Routine

Other Resources

API Library Routines by Category