Microcontroller C language (taking length string) component

___ simple, but a good memory as bad written ___
// get the length of the string (bytes)
 // * STR: string pointer
 // Return Value: length of a string     
unsigned char strlen (unsigned char * STR) 
{ 
    unsigned char len = 0 ;
     the while ( . 1 ) 
    {                              
        IF (STR * == ' \ 0 ' ) BREAK ; // copy completed. 
        len ++ ; 
        STR ++ ; 
    } 
    return len; 
}

 

Guess you like

Origin www.cnblogs.com/benhhs/p/11652856.html