远东HQ 2016-04-16 11:00 采纳率: 100%
浏览 1326

数据结构问题小白求解

我想得到这个顺序表的长度,为什么会给我得出一个7位数呢,显然不是啊。代码如下:
#include
#include
#define Max 15
typedef int ElemType;
typedef struct{
ElemType data[Max];
int length;

}SqList;

void CreateList(int n){
ElemType a[10];
SqList *L;
n=10;
L =(SqList *)malloc(sizeof(SqList));
for(int i=0;i L ->data[i]=a[i];
L ->length=n;

}
int ListLength(SqList *L){
return(L ->length);
}
main(){
printf("%d\n",ListLength);
return 0;
}

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-04-16 12:02
    关注
     printf("%d\n",ListLength);
    这里输出的是ListLength这个函数的地址,而不是长度
    应该是printf("%d\n",ListLength(你的链表));
    
    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制