Strncat () function in C
Char * strncat (char * dest, const char * src, size_t n) append (string), pointed to by src, at the end of the string pointed to by dest, with a length of up to n characters.
Char * strncat (char * dest, const char * src, size_t n) append (string), pointed to by src, at the end of the string pointed to by dest, with a length of up to n characters.
Declaring strncat () function in C
Here is the declaration for strncat () in C:
char * strncat ( char * dest , const char * src , size_t n )
Parameters
dest - This is the pointer to the destination array, which should contain a string, and should be large enough to contain the result string after being concatenated (including additional null characters).
src - This is the string to be appended at the end (append).
n - This is the maximum number of characters to be appended.
Returns the value
This function returns a pointer to the dest result string.
For example
The following C program illustrates the usage of strncat () in C:
#include #include int main () { char src [ 50 ], dest [ 50 ]; strcpy ( src , "Day la chuoi source (chuoi src)" ); strcpy ( dest , "Day la chuoi destination (chuoi dest) " ); strncat ( dest , src , 15 ); printf ( "Sau khi thuc hien ham strncat, chuoi dest co dang:n|%s|" , dest ); return ( 0 ); }
Compiling and running the above C program will result:
According to Tutorialspoint
Previous article: strcat function in C
Next lesson: strchr () function in C
You should read it
- The strlen () function in C
- The strcspn () function in C
- The strchr () function in C
- The strerror () function in C
- The strncpy () function in C
- Memset () function in C
- How to 'survive' with the stress of learning programming
- Bookmark a few tricks to help you master a programming language
- The strrchr () function in C
- Top 20 free programming learning websites need to bookmark immediately!
- Beginners of computer programming need to focus on what?
- Strcpy () function in C
Maybe you are interested
Nvidia just caused the 'blue screen of death' error for Windows Admire incredibly detailed images of the Orion Nebula through the eyes of the James Webb telescope This star 'tears up' its companion to create a rare beautiful nebula Admire the moment millions of new stars are born in the Lupus 3 nebula Before 'returning to Thanos', what was the fate and appearance of Nebula in the comics? How to create a blue screen of death (BSOD) to 'prank' friends