Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the strings and memory functions in C language

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "what are the strings and memory functions in c language". The content is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "what are strings and memory functions in c language".

one。 String function 1. Find the strlen of the string length

Size_t strlen (const char * str)

The string ends with'\ 0', and the strlen function returns the number of characters that appear before'\ 0' in the string (excluding'\ 0').

The string pointed to by the parameter must end with'\ 0'.

Note that the return value of the function is size_t, which is unsigned.

Simulation and implementation of strlen

Size_t my_strlen (const char*str) {size_t count=0; while (* str) {str++; count++;} 2. Compare strcmp of string size

Int strcmp (const char * str1, const char * str2)

Compare from the location where str1 and str2 point, if you encounter two unequal characters or the\ 0 function ends and returns a value.

The character of the first string is larger than that of the second string and returns a number > 0.

The character of the first string is equal to the character of the second string that returns a number of = 0.

The character of the first string whose character is less than the second string returns the ptr2 return value > 0

Ptr1=ptr2 return value = 0

Ptr1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report