Strcat function in C
The char * strcat function (char * dest, const char * src) append the string pointed to by src, at the end of the string pointed to by dest.
Declare the function strcat in C
Below is the declaration for strcat () in C:
char * strcat ( char * dest , const char * src )
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.
src - This is the string to be appended (append) at the end. This string should not overlap (stack) on the target string.
Returns the value
This function returns a pointer to the dest result string.
For example
The following C program illustrates the usage of strcat () 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) " ); strcat ( dest , src ); printf ( "Sau khi thuc hien ham strcat, chuoi dest la: n|%s|" , dest ); return ( 0 ); }
Compiling and running the above C program will result:
According to Tutorialspoint
Previous lesson: memset () function in C
Next lesson: strncat () function in C
You should read it
- Beginners of computer programming need to focus on what?
- Top 20 free programming learning websites need to bookmark immediately!
- Set of multiple choice questions about programming with P7 prize
- Set of multiple choice questions about programming with P11 prize
- P13 programming set of multiple choice questions
- Memset () function in C
- The strrchr () function in C
- Set of multiple choice questions about programming with P12
- Set of multiple choice questions for programming with P15 prize
- How to 'survive' with the stress of learning programming
- Set of multiple choice questions about programming with P10 prize
- 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