Many people think that the difficulty in the C language is pointer. Understanding the pointer is directly related to the quality of the compiled program. Therefore,
Here we list the source code of some standard functions that C compilers usually have. After reading them, we can view the pointer and string
I have some knowledge about it.
1. strlen (), calculate the string length
Int strlen (const char string)
{
Int I = 0;
While (string [I]) I ++;
Return I;
}
2. strcpy (), copy the string.
Char * strcpy (char * destination, const char * source)
{
While (* destinaton ++ = * source ++ );
Return (destination-1 );
}
3. strcat (), string connection.
Char * strcat (char * target, const char * source)
{
Char * original = target;
While (* target) target ++; // Find the end of the string
While (* target ++ = * source ++ );
Return (original );
}
4. streql () to determine whether two strings are equal.
Int streql (char * str1, char * str2)
{
While (* str1 = * str2) & (* str1 ))
{
Str1 ++;
<