After watching the machine learning course today, I changed to Learn C language for a while. It was also the first time I encountered the strcat function, the string concatenation function. Its general form is strcat (character array 1, character array 2). The function concatenates the strings of two character arrays, attaches string 2 to the end of string 1, and places the result in character array 1. The function call returns a function value — the address of character array 1. Such as:
#include<stdio.h>
int main()
{
char str1[30] = {"People's Republic of "};
char str2[] = {"China"};
printf("%s",strcat(str1,str2));
return 0;
}
Output code error:
In function 'main':
[Warning] incompatible implicit declaration of built-in function 'strcat'
Baidu once reason, little added header file
#include<stdlib.h>
#include<string.h>
After adding, the program output is normal: