课上程序的补充

#include<stdio.h>
#include<stdlib.h>
void funstr(char *s)
{
   
    while(*s!='\0')
    {
        printf("%c",*s);
        s++;
    }
}
int main()
{   

    char str[]="hello world";
    str[0]=str[0]-32;
    str[6]=str[6]-32;
    funstr(str);
    //system("pause");
    return 0;
}

运行结果:

Hello World
--------------------------------
Process exited after 0.01849 seconds with return value 0
请按任意键继续. . .

在课堂出现问题,cannot convert 'int *'to char *' for argument无法实现int 到char数据的转换,所以我重打了程序,运用while语句指针输出helloworld,把h和w的ASCII码值改变转换为大写。

posted on 2017-03-31 10:12  郭欣宇  阅读(104)  评论(0编辑  收藏  举报