]> pd.if.org Git - pdclib/blob - functions/string/strcpy.c
1fd3d32b9357c7d7265a0b1ad094e788e6accfea
[pdclib] / functions / string / strcpy.c
1 /* $Id$ */
2
3 /* strcpy( char *, const char * )
4
5    This file is part of the Public Domain C Library (PDCLib).
6    Permission is granted to use, modify, and / or redistribute at will.
7 */
8
9 #include <string.h>
10
11 #ifndef REGTEST
12
13 char * strcpy( char * _PDCLIB_restrict s1, const char * _PDCLIB_restrict s2 )
14 {
15     char * rc = s1;
16     while ( ( *s1++ = *s2++ ) );
17     return rc;
18 }
19
20 #endif
21
22 #ifdef TEST
23 #include <_PDCLIB_test.h>
24
25 int main( void )
26 {
27     char s[] = "xxxxx";
28     TESTCASE( strcpy( s, "" ) == s );
29     TESTCASE( s[0] == '\0' );
30     TESTCASE( s[1] == 'x' );
31     TESTCASE( strcpy( s, abcde ) == s );
32     TESTCASE( s[0] == 'a' );
33     TESTCASE( s[4] == 'e' );
34     TESTCASE( s[5] == '\0' );
35     return TEST_RESULTS;
36 }
37 #endif