c语言tolower()函数的使用问题,求解惑!
charstr1[][15]={"Zero","One","Two","Three","Four","Five","Six","Seven","Eight","nine"...
char str1[][15] = {"Zero","One","Two","Three","Four","Five","Six","Seven","Eight","nine"};
for(int i = 0; i < 10 ; i++)
str1[i][0] = tolower(str1[i][0]);
for(int j = 0 ; j < 10 ; j++)
printf(" %s ",str1[j]);
return 0;
为什么这段程序输出的内容会变成
zzro ooe tto ttree ffur ffve.....
在把str1[j] 数组中的字符串首个大写字母转换成小写字母后,会把str1[j]中 各个字符串的第二个字母覆盖掉?谁给我讲讲是什么原因 展开
for(int i = 0; i < 10 ; i++)
str1[i][0] = tolower(str1[i][0]);
for(int j = 0 ; j < 10 ; j++)
printf(" %s ",str1[j]);
return 0;
为什么这段程序输出的内容会变成
zzro ooe tto ttree ffur ffve.....
在把str1[j] 数组中的字符串首个大写字母转换成小写字母后,会把str1[j]中 各个字符串的第二个字母覆盖掉?谁给我讲讲是什么原因 展开
2个回答
展开全部
程序没有问题。
如果是 c 程序,应把 int i,j; 声明放到语句以前。c++ 可以这样放。
c 程序如下:
#include <stdio.h>
main()
{
char str1[][15] = {"Zero","One","Two","Three","Four","Five","Six","Seven","Eight","nine"};
int i,j;
for(i = 0; i < 10 ; i++)
str1[i][0] = tolower(str1[i][0]);
for(j = 0 ; j < 10 ; j++)
printf(" %s ",str1[j]);
return 0;
}
输出:
zero one two three four five six seven eight nine
如果是 c 程序,应把 int i,j; 声明放到语句以前。c++ 可以这样放。
c 程序如下:
#include <stdio.h>
main()
{
char str1[][15] = {"Zero","One","Two","Three","Four","Five","Six","Seven","Eight","nine"};
int i,j;
for(i = 0; i < 10 ; i++)
str1[i][0] = tolower(str1[i][0]);
for(j = 0 ; j < 10 ; j++)
printf(" %s ",str1[j]);
return 0;
}
输出:
zero one two three four five six seven eight nine
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询