当前位置: 代码迷 >> C语言 >> 我很笨,有个问题
  详细解决方案

我很笨,有个问题

热度:327   发布时间:2008-06-28 09:38:30.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  

----------------解决方案--------------------------------------------------------
有逗号,是输出2串字符
----------------解决方案--------------------------------------------------------
如果没有逗号,那",that is the question."就没意义了,因为这永远也不会显示出来
----------------解决方案--------------------------------------------------------
  相关解决方案