Changeset 619 for trunk/libs/mini-libc
- Timestamp:
- Feb 12, 2019, 1:15:47 PM (6 years ago)
- Location:
- trunk/libs/mini-libc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libs/mini-libc/string.c
r473 r619 80 80 81 81 82 ////////////////////////// /83 char * strcpy (char * d est,82 ////////////////////////// 83 char * strcpy (char * dst, 84 84 char * src ) 85 85 { 86 char *src_ptr = src; 87 char *dst_ptr = dest; 88 89 while(*src_ptr) *(dst_ptr++) = *(src_ptr++); 90 91 *dst_ptr = 0; 92 return dest; 93 } 94 95 //////////////////////////////////// 96 char * strncpy( char * dest, 86 while( *src ) 87 { 88 *(dst) = *(src); 89 dst++; 90 src++; 91 } 92 93 // set NUL terminating character 94 *dst = 0; 95 96 return dst; 97 } 98 99 /////////////////////////////////// 100 char * strncpy( char * dst, 97 101 char * src, 98 unsigned int n)102 unsigned int count ) 99 103 { 100 104 unsigned int i; 101 105 102 for (i = 0; (i < n) && (src[i] != '\0') ; i++) dest[i] = src[i]; 103 104 for (; i < n; i++) dest[i] = '\0'; 105 106 return dest; 106 // copy at most count characters 107 for (i = 0 ; (i < count) && (src[i] != '\0') ; i++) dst[i] = src[i]; 108 109 // complete with NUL characters 110 for ( ; i < count ; i++) dst[i] = '\0'; 111 112 return dst; 107 113 } 108 114 -
trunk/libs/mini-libc/string.h
r445 r619 70 70 * @ return 0 if s1 == s2 / return 1 if s1 > s2 / return -1 if s1 < s2 71 71 *******************************************************************************************/ 72 int strncmp ( const char * s1,73 const char * s2,72 int strncmp ( const char * s1, 73 const char * s2, 74 74 unsigned int n ); 75 75 … … 84 84 85 85 /******************************************************************************************** 86 * This function copies < n> characters from the <sr> buffer to the <dst> buffer.86 * This function copies <count> characters from the <src> buffer to the <dst> buffer. 87 87 ******************************************************************************************** 88 88 * @ dst : pointer on destination buffer. 89 89 * @ src : pointer on source buffer. 90 * @ n: number of characters to be copied.90 * @ count : number of characters to be copied. 91 91 *******************************************************************************************/ 92 92 char * strncpy ( char * dst, 93 93 char * src, 94 unsigned int n);94 unsigned int count ); 95 95 96 96 /********************************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.