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