码迷,mamicode.com
首页 > 其他好文 > 详细

课堂作业补充

时间:2017-03-31 10:15:20      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:[]   --   after   stdio.h   value   val   补充   导致   for   

#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
请按任意键继续. . .

 

课堂作业补充

标签:[]   --   after   stdio.h   value   val   补充   导致   for   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!