1. strlen (), Calculate string length
Copy Code code as follows:
int strlen (const char string)
{
int i=0;
while (String[i]) i++;
return i;
}
2. strcpy (), string copy.
Copy Code code as follows:
Char *strcpy (char *destination, const char *source)
{
while (*destinaton++=*source++);
return (destination-1);
}
3. Strcat (), string connection.
Copy Code code as follows:
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.
Copy Code code as follows:
int streql (char *str1,char *str2)
{
while ((*STR1==*STR2) && (*STR1))
{
str1++;
str2++;
}
Return ((*str1==null) && (*str2==null));
}
5. STRCHR (), find a character in the string.
Copy Code code as follows:
Char *strchr (const char *string,int letter)
{
while ((*string!=letter) & (*string))
string++;
return (string);
}
6. CHRCNT (), calculates the number of times a character appears in a string.
Copy Code code as follows:
int chrcnt (const char *string,int letter)
{
int count=0;
while (*string)
if (*string==letter) count++;
return count;
}
7. strcmp () to determine whether two strings are equal.
Copy Code code as follows:
int strcmp (const char *str1,const char *STR2)
{
while ((*STR1==*STR2) && (*STR1))
{
str1++;
str2++;
}
if ((*STR1==*STR2) && (!*STR1))//same strings
return o;
else if ((*STR1) && (!*STR2))//same but str1 longer
return-1;
else if ((*STR2) && (!*STR1))//same but str2 longer
Else
Return ((*STR1>*STR2) -1:1);
}