c语言中的const修饰符

来源:百度知道 编辑:UC知道 时间:2024/09/23 17:11:17
#include<stdio.h>
void fun_con(cost char *str);
main()
{
char str[]={'a','b','c','d','e'};
fun_con(str);
printf("%s\n",str);
return 0;
}

void fun_con(const char *str)
{
while(*str)
{
printf("%c\n",toupper(*str++));
}
printf("\n");
}
这个程序那里错了。

#include<stdio.h>
#include <ctype.h> \\这里加个头文件
void fun_con(const char *str); \\这里const错了
main()
{
char str[]={'a','b','c','d','e','\0'}; \\这里加个结束的\0
fun_con(str);
printf("%s\n",str);
return 0;
}

void fun_con(const char *str)
{
while(*str)
{
printf("%c\n",toupper(*str++));
}
printf("\n");
}

已经正确运行
#include<stdio.h>
void fun_con(const char *str);
main()
{
char str[]={'a','b','c','d','e'};
fun_con(str);
printf("%s\n",str);
return 0;
}

void fun_con(const char *str)
{
while(*str)
{
printf("%c\n",toupper(*str++));
}
printf("\n");
}

错误改正:
v