鱼C论坛

 找回密码
 立即注册
查看: 3893|回复: 4

使用"&"字符引用出现的错误,大神们,触手救救我吧

[复制链接]
发表于 2012-11-3 16:44:20 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
#include "malloc.h"
#include <STDIO.H>
#include >

#define MaxSize 50
typedef char ElemType;
typedef struct
{
        ElemType data[MaxSize];
        int len;
}SqList;


void CreateList(SqList *&L,ElemType a[],int n)
{
        int i;
        L=(SqList *)malloc(sizeof(SqList));
        for(i=0;i<n;i++)L->data[i]=a[i];
        L->length=n;
}
void InitList(SqList *&L)
{
        L=(SqList *)malloc(sizeof(SqList));
        L->length=0;
}
void DestroyList(SqList *&L)
{
        free(L);
}
int ListEmpty(SqList *L)
{
        return(L->length==0);
}
int ListLength(SqList *L)
{
        return(L->length);
}
void DispList(SqList *L)
{
        int i;
        if (ListEmpty(L))return;
        for(i=0;i<L->length;i++)printf("%c",L->data[i]);
        printf("\n");
}
int GetElem(SqList *L,int i,ElemType &e)
{
        if(i<1||i>L->length )return 0;
        e=L->data[i-1];
        return 1;
}
int LocateElem(SqList *L,ElemType e)
{
        int i=0;
        while(i<L->length&&L->data[i]!=e)i++;
        if(i>=L->length)
                return 0;
        else
                return i+1;
}
int ListInsert(SqList *L,int i,ElemType e)
{
        int j;
        if(i<1||i>L->length+1)return 0;
        i--;
        for(j=L->length;j>i;j--)L->data[j]=L->data[j-1];
        L->data[i]=e;
        L->length++;
        return 1;
}
int ListDelete(SqList *&L,int i,ElemType &e)
{
        int j;
        if(i<1||i>L->length)return 0;
        i--;
        e=L->data[i];
        for(j=i;j<L->length;j++)L->data[j]=L->data[j+1];
        L->length--;
        return 1;
}
void main()
{
.....
}
其中编译是出现错误
syntax error : missing ')' before '&'
syntax error : missing '{' before '&'
syntax error : '&'
错误的地方是函数定义是使用引用指针做参数的"&"引用符出错!
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-11-3 16:56:31 | 显示全部楼层
  1. #include <STDIO.H>
  2. #include >

  3. #define MaxSize 50
复制代码
#include >  这是什么??
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-11-3 17:05:29 | 显示全部楼层
哎,仔细的看了一下,错了很多地方,估计是你复制给漏掉了。。关键是不太清楚你函数的意图,所以无法帮你修改了
小甲鱼最新课程 -> https://ilovefishc.com
 楼主| 发表于 2012-11-4 21:23:43 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
 楼主| 发表于 2012-11-4 21:24:44 | 显示全部楼层
虎子 发表于 2012-11-3 17:05
哎,仔细的看了一下,错了很多地方,估计是你复制给漏掉了。。关键是不太清楚你函数的意图,所以无法帮你修 ...

谢谢你们的回复,现在我已经找到问题的所在了.原因是在cpp文件中才兼容*&连用,在c下不兼容..
小甲鱼最新课程 -> https://ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-11-16 02:11

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表