关于引用的一个细节

看如下代码:(这段代码用.c文件存放,用C编译器编译)
#include<stdio.h>
#include<stdlib.h>
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10

typedef struct SQ{
 int *elem; //存储空间基址
 int length;
 int listsize;
}SqList,pSqList;

void InitList_Sq(SqList &Lt)
{
 Lt.elem=(int *)malloc(LIST_INIT_SIZE*sizeof(int));
    if(!Lt.elem)
  exit(0);
 Lt.length=0;
 Lt.listsize=LIST_INIT_SIZE;
}
void main()
{
 SqList L1;
 InitList_Sq(L1);
 printf("%d",L1.length);
}
请问:这段代码有什么问题吗???
//
有问题!!!!!!!!!!!!!
在哪???????????????
我们编译发现,会出现如下错误:
--------------------Configuration: sxb - Win32 Debug--------------------
Compiling...
sxb.c
E:/VC6.0 Workspace/ccc/sxb.c(12) : error C2143: syntax error : missing ')' before '&'
E:/VC6.0 Workspace/ccc/sxb.c(12) : error C2143: syntax error : missing '{' before '&'
E:/VC6.0 Workspace/ccc/sxb.c(12) : error C2059: syntax error : '&'
E:/VC6.0 Workspace/ccc/sxb.c(12) : error C2059: syntax error : ')'
E:/VC6.0 Workspace/ccc/sxb.c(23) : warning C4013: 'InitList_Sq' undefined; assuming extern returning int
Error executing cl.exe.

sxb.obj - 4 error(s), 1 warning(s)
///
解决方案:
1,将文件改为.cpp格式
或2,去掉引用,改为指针,这样的话,其他地方也要改该
原因是:在C语言中没有引用这个概念,不存在引用,在C++中才有

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值