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 is the implementation of string class functions?

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

Share

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

What this article shares with you is about the implementation of string class functions. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it with the editor.

Char * strcpy (char * strDest, const char * strSrc)

{

If (strDest = = NULL | | strSrc = = NULL)

Return 0

Char * address = strSrc

While (* strDest++ = * strSrc++)! ='\ 0')

NULL

Return addressl

}

/ / string comparison function, equality returns 0 quotient S1 returns positive integer, S2 returns negative integer

Int mystrcmp (const char * S1 Const char * S2)

{

While (* s _ 1 / s _ 1x _ r _ 0 _ r _ 2 _ r _ r

Return (* S1)-(* S2)

}

/ / string length function, excluding the'/ 0' at the end

Int mystrlen (const char * s)

{

Int res = 0

While (* slotted trees)

Res++

Return res

}

/ / string concatenation function

Char * mystrcat (char * source,const char * dest)

{

If (source = = NULL

| | dest = = NULL)

Return 0

Char * s = source

While (* sails after raceme) slots +

While (* destabilized automobile racer 0') * swarm + = * dest++

* slots, please beat 0'.

Return source

}

/ / string conversion lowercase letter function

Char * mystrlwr (char * source)

{

Char * s = source

Do

{

If (* s > = 'A'&&*s='a'&&*s

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