标题:这个部分填充数组有什么问题吗,怎么结果很奇葩
只看楼主
Liekkas
Rank: 1
等 级:新手上路
帖 子:12
专家分:3
注 册:2015-1-22
结帖率:100%
 问题点数:0 回复次数:2 
这个部分填充数组有什么问题吗,怎么结果很奇葩
#include"stdio.h"
void
full_to_sentinel(int maxi,double full[],int endwords,int *truthip);
int
main(void)
{
    double fulla[];
    int maxia=5;
    int  endwordsa=-1;
    int i;
    int j;
    full_to_sentinel(maxia,&fulla[],endwordsa,&i);
    printf("列出数组中的元素。\n");
    for(j=0;j<i;++j)
      {
              printf("%13.3f\n",fulla[j]);
      }
      return 0;
}
void
full_to_sentinel(int maxi,double full[],int endwords,int *truthip)
{
    int i;
    double data;
    int status;
    i=0;
    printf("请输入数据。\n");
    status=scanf("%lf",&data);
    while (status==1&&data!=endwords&&i<maxi)
        {
             full[i]=data;
             ++i;
             printf("请输入数据。\n");
            status=scanf("%lf",&data);
        }
    if (status!=1)
          {
               printf("您输入的的数据有误,不符合数据类型。\n");
          }else
            {
                if (data!=endwords)
                  printf("您输入的的数据超出预期数目。\n");
            }
     *truthip=i;
}
搜索更多相关主题的帖子: include double return status 元素 
2015-02-07 10:19
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:507
帖 子:8890
专家分:53117
注 册:2011-1-18
得分:0 
"怎么结果很奇葩"
 ------ 你输入了什么,实际输出了什么,期待输出什么?这三点你不告诉别人,别人是无法回答你。

另外,我看了一下,&fulla[] 能编译通过吗?既然都不能运行,你哪来的“怎么结果很奇葩”?
2015-02-07 10:34
奋斗五天
Rank: 2
等 级:论坛游民
帖 子:5
专家分:10
注 册:2014-9-16
得分:0 
c语言建立数组需要初始化大小
double fulla[];
传数组时只需传递数组名就可
full_to_sentinel(maxia,&fulla[],endwordsa,&i);
2015-02-07 11:37



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




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

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