标题:我很笨,有个问题
取消只看楼主
不就编程
Rank: 1
来 自:常州
等 级:新手上路
帖 子:6
专家分:0
注 册:2008-6-26
 问题点数:0 回复次数:0 
我很笨,有个问题
我在看字符串一章,有个问题:
一个十分简单的程序:

#include<stdio.h>
int main(void)
{
  char w[][100]={
                "To be or not to be", (此处是否要逗号,教材上有时有,有时无)
           ",that is the question."
               };
  int count[]={0,0};
  while(w[0][count[0]++]);
  while(w[1][count[1]++]);
  
  if(sizeof w[0]<count[0]+count[1]+1)
   printf("ERROR!");
  else
   {
    count[1]=0;
    while(w[0][1+count[0]++]=w[1][count[1]++]);
   };
   printf("输出:%s",w[0]);
   return 0;
}

有逗号结果是  To be or not to be
无逗号结果是  To be or not to be,that is the question.

[[it] 本帖最后由 不就编程 于 2008-6-28 09:40 编辑 [/it]]
搜索更多相关主题的帖子: void main char includeint return 
2008-06-28 09:38



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-221673-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.496544 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved