首页 > 其他 > 详细

课上程序的补充

时间:2017-03-31 00:25:21      阅读:134      评论:0      收藏:0      [点我收藏+]
#include"stdio.h"
#include"string.h"
int main()
{
    void funstr(char str[]);
    char str[]="hello world";
    str[0]=H;
    str[6]=W;
    printf("%s\n",str);
    funstr(str);
   
 } 
 void funstr(char str[])
 {
     int i;
     i=0;
     while(str[i]!=\0)
     {
         printf("%c\n",str[i++]);
         }
     }

运行结果:

Hello World
H
e
l
l
o

W
o
r
l
d

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

 

总结:在课堂上没有对i 赋予初值,大小写可以转换,但是一直显示程序出错,下次要注意定义一个整型,弄清楚函数的形式和要求。

课上程序的补充

原文:http://www.cnblogs.com/cccyb/p/6649204.html

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