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:
Read More:
- Error c2137 of C language: empty character constant (Fixed)
- The function and usage of argc and argv in C language
- CIN in C + + cin.get ()、 cin.getline (), getline(), gets() function
- C / C + + library function (tower / tower) realizes the conversion of letter case
- Conversion from hexadecimal to decimal
- The usage and difference of atoi() and stoi() functions in C + +
- error: a label can only be part of a statement and a declaration is not a statement (How to Fix)
- Analysis of compilation errors of “error conflicting types for function”
- error C2137: empty character constant
- Errno in Linux Programming
- [leetcode] zigzag transformation
- The language of C__ FILE__ 、__ LINE__ And line
- Differences between length() size() and C strlen() of C + + string member functions
- error C2057: expected constant expression (Can the size of an array in C language be defined when the program is running?)
- C + + pauses the black window system (“pause”); (get ch(), getchar(), system (pause)’s connection and difference
- Write about the problems and solutions when configuring OpenGL in vs2015
- When MATLAB uses audioread, an error is reported: Error using which Must be a string scalar or character vector.
- C++ string substr()
- C language write() function analysis: write failed bad address
- pthread_ Introduction and application of join function