<>C language strcat Explanation of library function

<>MSDN about strcat Introduction to library functions

<> analysis :

From the above MSDN about strcat Introduction of library functions , We can clearly know strcat The header file of the library function is <string.h>, The two parameters received are the destination parameter and the source parameter ,strcat The function of the library is to connect the content of the source parameter to the content of the destination parameter , then strcat The library function finally returns the content of the destination parameter .

<> Simulation Implementation ( Graphic thinking ):

<> Code demonstration :

<> Code extraction :
#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<string.h> #include
<assert.h> char *my_strcat(char *strDestination, const char *strSource) { assert
(strDestination && strSource);// Prevent null pointers from being passed in , In this way, you can report errors directly char *ret = strDestination;
// because strcat The return type of is char* Type , So we define a char* A variable of type will be used later to return , Initializes to a pointer variable that points to the destination array while (*
strDestination++ != '\0');// The destination pointer variable needs to be found first \0 Element of , Then you can start from the destination array \0 Location connection while (*
strDestination++ = *strSource++);// Start from destination array \0 Connect the contents of the source array at the location of , Until the source array is found \0 Stop connecting until
return ret;// Returns the connected array } int main() { char arr1[40] = "ToadWantToEat"; char arr2[
] = "SwanMeat"; printf("%s\n", strcat(arr1, arr2));// In the library printf("%s\n",
my_strcat(arr1, arr2));// Simulated Implementation return 0; }
remarks : The landlord is not talented , Don't spray if you don't like it , If there are mistakes or areas that need to be improved , Thank you very much for pointing out , I will actively learn and adopt . Thank you for your support and encouragement , I will continue to work hard to create more high-quality articles and report back to my family . Programming hobby xdm, If there are problems in programming learning, you can discuss them with me in private ( I'll try my best to help you ), after all “ People gather firewood and the flame is high ”, Let's exchange and study together , Common progress !