Get the App
SLTechnology News&Howtos  ›  Development  › 

Introduction and concrete usage of strcat_s function in C language

Shulou Source: shulou.com Published: 2022-06-03 17:22:39 11月13日 Update

This article mainly introduces "the introduction and specific use of the c language strcat_s function". In the daily operation, I believe that many people have doubts about the introduction and specific use of the c language strcat_s function. The editor consulted all kinds of materials and sorted out the simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about the introduction and specific use of the c language strcat_s function. Next, please follow the editor to study!

1. Strcat_s is the security function of the system, which is used to concatenate strings and concatenate two strings together.

2. Strcat_s replaces the strcat function, which can avoid the problem of program crash.

The original strcat function has no way to guarantee a valid buffer size, so it can only assume that the buffer is large enough to cause the program to crash.

Example

# include "stdafx.h" # include # include int main () {_ CrtSetReportMode (_ CRT_ERROR, 0); char str1 [] = "Hello,"; char str2 [] = "world"; int num = strlen (str1) + strlen (str2) + 1; errno_t rlt = strcat_s (str1, num, str2); if (rlt = 0) std::cout

Tags: Functions methods methods of use languages learning characters strings more programs problems help buffering utility effectiveness security next two methods size examples Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux OPPO Reno Redmi Microsoft Shulou Tech Info