strcpy_s, wcscpy_s
Go Up to string.h Index
Header File
string.h, _str.h
Category
Memory and String Manipulation Routines, Inline Routines
Prototype
errno_t strcpy_s(char * _RESTRICT dest, rsize_t destmax, const char * _RESTRICT src);
errno_t wcscpy_s(wchar_t * _RESTRICT dest, rsize_t destmax, const wchar_t * _RESTRICT src);
Description
Replaces strcpy adding security enhancements.
Copies one string into another.
Copies string src to dest, stopping after the terminating null character has been moved. If src and dest overlap, no copying is made. If there is a run-time constraint violation, s[0] is set to null.
Return Value
strcpy_s returns zero if successful, nonzero otherwise.
Example
#include <stdio.h> #include <string.h> int main(void) { char string[10]; char *str1 = "abcdefghi"; strcpy_s(string, 10, str1); printf("%s\n", string); return 0; }
Portability
POSIX | Win32 | ANSI C | ANSI C++ | |
---|---|---|---|---|
strcpy_s |
+ |
+ |
+ |
+ |