strncat
Go Up to string.h Index
Header File
string.h, mbstring.h
Category
Memory and String Manipulation Routines, Inline Routines
Prototype
char *strncat(char *dest, const char *src, size_t maxlen);
wchar_t *wcsncat(wchar_t *dest, const wchar_t *src, size_t maxlen);
unsigned char *_mbsncat(unsigned char *dest, const unsigned char *src, size_t maxlen);
unsigned char *_mbsnbcat(unsigned char *__dest, const unsigned char *__src, _SIZE_T __maxlen);
Description
Appends a portion of one string to another.
strncat copies at most maxlen characters of src to the end of dest and then appends a null character. The maximum length of the resulting string is strlen(dest) + maxlen.
The first three functions behave identically and differ only with respect to the type of arguments and return types.
For _mbsnbcat, if the second byte of 2-bytes character is null, the first byte of this character is regarded as null. _mbsnbcat also copies at most maxlen
bytes, not characters as the other functions do.
Return Value
strncat returns dest.
Example
#include <string.h> #include <stdio.h> int main(void) { char destination[25]; char *source = " States"; strcpy(destination, "United"); strncat(destination, source, 7); printf("%s\n", destination); return 0; }
Portability
POSIX | Win32 | ANSI C | ANSI C++ | |
---|---|---|---|---|
strncat |
+ |
+ |
+ |
+ |
_mbsncat |
+ |
|||
_mbsnbcat |
+ |
|||
_wcsncat |
+ |