strcpy
Syntax
Defined in
Description
Example
strcspn
Syntax
Defined in
Description
Example
String Copy
#include <string.h>
char *strcpy(char *string1, const char *string2 );
strcpy.c in rts.src
The strcpy function copies string2 (including a terminating null character) into
string1. If you attempt to copy strings that overlap, the function's behavior is
undefined. The function returns a pointer to string1. The strcpy function is ex-
panded inline when the −x option is used.
In the following example, the strings pointed to by *a and *b are two separate
and distinct memory locations. In the comments, the notation \0 represents
the null character:
char *a = "The quick black fox";
char *b = " jumps over ";
/* a −−> "The quick black fox\0"
/* b −−> " jumps over \0"
strcpy(a,b);
/* a −−> " jumps over \0"
/* b −−> " jumps over \0"
Find Number of Unmatching Characters
#include <string.h>
size_t strcspn(const char *string, const char *chs );
strcspn.c in rts.src
The strcspn function returns the length of the initial segment of string1, which
is made up entirely of characters that are not in string2. If the first character
in string1 is in string2, the function returns 0.
char *stra = "who is there?";
char *strb = "abcdefghijklmnopqrstuvwxyz";
char *strc = "abcdefg";
size_t length;
length = strcspn(stra,strb);
length = strcspn(stra,strc);
*/
*/
*/
*/
/* length = 0 */
/* length = 9 */
Run-Time-Support Functions
strcspn
7-49
Need help?
Do you have a question about the TMS320C2x and is the answer not in the manual?