浅谈 my_strlwr和my_strupr 把大写字符串转化为小写

   
#include
#include
#include

char * my_strlwr( char *Str )
{
	assert( NULL != Str );
	char *p = Str;
	while('\0' != *p)
	{
		if((*p>='A')&&(*p<='Z'))
			*p+='a'-'A';
		p++;
		
	}
	return Str;
} 
char * my_strupr( char *Str )
{
	assert( NULL != Str );
	char *p = Str;
	while('\0'!=*p)
	{
		if((*p>='A')&&(*p<='Z'))
			*p-='a'-'A';
		p++;
		
	}
	return Str;
} 
int main()
{
	char p[]={'A','B','C','\0'};
	printf("%s\n",my_strlwr(p));//printf只会找到\0才会停止
	return 0;
}

 
 

你可能感兴趣的:(C)