2012年11月5日 星期一

ANCI C 字串轉小寫( string convert lower case)

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

char *dot_location = "ABCDEF";
int String_length;
if ( dot_location != NULL  )
        {
            String_length = strlen ( dot_location );
            dot_location = tolower_extension( dot_location , String_length);
        }


.....
........
............
char *tolower_extension( char *dot_location , int length   )
{
   
           printf ( "length= %d\n" , length);
           int i ;
            for (i = 1 ; i < length + 1 ; i++ )
            {
                dot_location[i] = tolower( dot_location[i] );          
            }   
            printf( "%s\n", dot_location );
           
   
    return dot_location;
}     


====output================================
 length=6  (p.s: strlen don't include NULL character)
 abcdef

沒有留言:

張貼留言