strncat_s, wcsncat_s
Go Up to string.h Index
Header File
string.h, mbstring.h
Category
Memory and String Manipulation Routines, Inline Routines
Prototype
errno_t *strncat(char * _RESTRICT dest, rsize_t destmax, const char * _RESTRICT src, rsize_t n);
errno_t *wcsncat(wchar_t * _RESTRICT dest, rsize_t destmax, const wchar_t * _RESTRICT src, rsize_t n);
Description
Replaces strncat adding security enhancements.
Appends a portion of one string to another.
strncat_s copies at most n characters from src to the end of dest. The maximum length of the resulting string is strlen(dest) + destmax.
If there is a run-time constraint violation, dest[0] is set to the null character.
Return Value
Returns zero if successful, nonzero otherwise.
Example
#include <string.h>
#include <stdio.h>
int main(void)
{
char destination[25];
char *source = " States";
strcpy_s(destination, 7, "United");
strncat_s(destination, 14, source, 7);
printf("%s\n", destination);
return 0;
}
Portability
| POSIX | Win32 | ANSI C | ANSI C++ | |
|---|---|---|---|---|
|
strncat_s |
+ |
+ |
+ |
+ |
|
wcsncat_s |
+ |