首页 > 其他 > 详细

课堂作业补充

时间:2017-03-31 10:15:20      阅读:170      评论:0      收藏: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
请按任意键继续. . .

 

课堂作业补充

原文:http://www.cnblogs.com/tkh666/p/6649831.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!