You can use the C run-time string functions to handle strings. However, in the small and medium memory models, these functions do not handle strings declared as far pointers or arrays, such as a dynamically allocated global memory object created by the GlobalAlloc function. The C run-time buffer-manipulation functions (such as memcpy and memset) are subject to the same restrictions in the small and medium models.Windows provides the following functions for handling far strings:
To compare or test characters in the Windows character set, use the following functions instead of the equivalent C run-time functions: <$IWindows character set;comparing or testing characters>
Windows uses a different collating sequence than do the C run-time functions.
Windows also provides the wsprintf and wvsprintf functions as replacements for the C run-time sprintf and vsprintf functions. The Windows versions have the following advantages:
They use far buffers rather than near buffers.
They are much smaller.
They allow you to eliminate the C startup code if your application does not require other C run-time functions. For more information, see Section 14.5.10, “Eliminating C Run-Time Startup Code.”
Note that the Windows versions support only a subset of the string format specifications. In particular, they do not support floating-point formats, pointer format, and octal base.
Important:
If you replace a sprintf or vsprintf function with its equivalent Windows function, be sure to cast any string passed as a %s argument to a far pointer:
char buffer[100];
char *str1; /* near pointer in small or medium model */
.
.
.
sprintf(buffer,"Str1=%s",str1); /* Valid */
wsprintf(buffer,"Str1=%s",(LPSTR)str1); /* Valid */
wsprint(buffer,"Str1=%s",str1); /* INVALID */