home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name stcleft -- Extract leftmost characters from a string
- *
- * Synopsis amov = stcleft(ptarget,psource,cnt,tarsize)
- *
- * int amov Actual number of characters moved
- * char *ptarget Pointer to target string
- * char *psource Pointer to source string
- * int cnt Number of characters to extract
- * int tarsize Maximum size of ptarget
- *
- * Description This function extracts the cnt leftmost characters from
- * psource and returns the characters in ptarget. The
- * number of characters extracted is no greater than the
- * length of the source string, or the maximum size of the
- * target string minus 1 (to account for the trailing
- * '\0'). The actual number of characters extracted is
- * returned as the function value.
- *
- * Returns amov The number of characters extracted.
- * ptarget The string of extracted characters.
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1983, 1984, 1986
- *
- **/
-
- #include <bstring.h>
-
- int stcleft(ptarget,psource,cnt,tarsize)
- register char *ptarget,*psource;
- register int cnt;
- int tarsize;
- {
- register int i;
-
- utbound(cnt,0,tarsize - 1) /* Number of characters to move.*/
- for (i = 0; (i < cnt) && (*ptarget++ = *psource++); i++)
- ;
- *ptarget = '\0';
-
- return(i);
- }