//作为标准C/C++ ,这里的函数都是标准库里的函数
1字符串拷贝
(1)char * strcpy(char * dest, const char * src)
//来自cppreference: http://www.cplusplus.com/reference/clibrary/cstring/strcpy/
功能: 把src指向的字符串拷贝到dest指向的位置,包括'/0'。拷贝回直到src结尾位置。
Copies the C string pointed by source into the array pointed by destination, including the terminating null character.
To avoid overflows, the size of the array pointed by destination shall be long enough to contain the same C string as source (including the terminating null character), and should not overlap in memory with source.
(2) char * strncpy( char * dest, const char * src, size_t num)
至多拷贝num个src指向的字符到dest处。 如果直到src的第num个字符都没有遇到'/0',那么就拷贝这num个字符,不会再补充一个'/0'了。如果遇到了'/0‘, 那么就在此位置一直num设置为'/0'
//来自cppreference: http://www.cplusplus.com/reference/clibrary/cstring/strcpy/
Copy characters from string
No null-character is implicitly appended to the end of destination, so destination will only be null-terminated if the length of the C string in source is less than num.
Parameters
-
destination
- Pointer to the destination array where the content is to be copied. source
- C string to be copied. num
- Maximum number of characters to be copied from source.
Return Value
destination is returned.
7289

被折叠的 条评论
为什么被折叠?



