使用数组地址偏移将元素中的大写字母转化为小写字母,计算被转换的个数,并打印转换前后array中的字符
#include
#define n 20
main()
{
char *a=NULL;
unsigned int change_sum=0;
unsigned int loop=0;
char array[n]={'a','B','N','8','M','D',',','*','0','X','m','4','y','Z','!','t','U','T','k','@'};
a=array;
for(loop =0;loop<n;loop++)
{
if((loop%5)==0)
{
printf("\n");
}
printf("%-4c",*a++);
}
printf("\n*********************\n\n");
a=array;
for(loop =0;loop<n;loop++)
{
if(('A'<=*a)&&(*a<='Z'))
{
*(array+loop)=*a+'a'-'A';
change_sum++;
}
if((loop%5)==0)
{
printf("\n");
}
printf("%-4c",*a);
a++;
}
printf("\nchange_sum=%u\n",change_sum);
}