代码改变世界

课堂作业补充

2017-03-31 09:58  htua  阅读(159)  评论(0编辑  收藏  举报
#include<stdio.h>
#include<stdlib.h>
void funstr(char *s)
{
    int a=0;
    while(*(s+a)!='\0')
    {
        printf("%c",*(s+a++));
    }
    printf("\n");
    printf("%s",s);
}
int main()
{
    char str[]="hello world";
    str[0] = 'H';
    str[6] = 'W';
    funstr(str);
    system("pause");
    return 0;
}

这是正确代码  

#include<stdio.h>
#include<stdlib.h>
void funster(char s[])
{
    int a=0;
    while((s+a)!='\0')
    {
        printf("%c",s+a++);
    }
    printf("\n");
    printf("%s",s);
}
int main()
{
    char str[]="hello world";
    str[0] = 'H';
    str[6] = 'W';
    funstr(str);
    system("pause");
    return 0;
}

这是我上课时的代码

刚开始我打算用for ,经过室友的帮助 建议我运用while  之后由于忘记打地址疯狂输出,导致只能重启

知道经过老师的点播 发现函数名打错

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