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.
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
The world's oldest and most famous gaming magazine has just closed
The world's widest boulevard with 16 lanes was completed half a century ago
Korea stirs because robot employee 'self-destructs'
Billionaire Musk's SpaceX took on the job of destroying the ISS
Nostradamus and prophecies about the world's destiny in 2021
Ms. Vanga and shocking predictions about the world's destiny in 2023