Home > Back-end >  Why is my builder will prompt I add ";" ", "or") "?
Why is my builder will prompt I add ";" ", "or") "?

Time:09-23

This program is our teacher to the framework of data structure
After I had finished my function, there is always an error//error: expected '; ', ', 'or') 'before' & amp; 'token
I would like to ask about the reasons for this problem, thank you all for elder
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#include
#include
#include//the malloc ()?
#include//INT_MAX?
#include//EOF (=^ Z? F6), NULL
#include//the atoi ()
#include//eof ()
#include//floor (), the ceil (), abs ()
#include//the exit ()

# define TRUE 1
# define FALSE 0
# define OK 1
# define the ERROR 0
# define INFEASIBLE - 1

Typedef int the Status;
# define LIST_INIT_SIZE 10
# define LISTINCREMENT 2
Typedef ElemType;
Typedef struct
{
ElemType * elem;
int length;
Int listsize;
} SqList;

The Status InitList (SqList & amp; L)
{//constructs an empty sequence table
L.e lem=(ElemType *) malloc (LIST_INIT_SIZE * sizeof (ElemType));
if(! L.e lem)
The exit (OVERFLOW);
L.l ength=0;
L.l istsize=LIST_INIT_SIZE;
return OK;
}

The Status DestroyList (SqList & amp; L)
{//destroy order linear table L
If (L.e lem)
Free (L.e lem);
}

Int LocateElem (SqList L, ElemType e)
{//according to the value of the data element, returns its position in the linear table L
int i=0;
While ((i<=L.l ength) & amp; & (* (L.e lem + I - 1)!=e))
I++;
If (i<=L.l ength)
return i;
The else
The return (1);
}

Status GetElem (SqList L, int I ElemType & amp; E)
{//according to the position of data element in the linear table L, returns its value
If (i<1 | | i> L.l ength)
Return the ERROR;
E=* (L.e lem + I - 1);
Return OK
}

The Status ListInsert (SqList & amp; L, int I ElemType e)
{//in L in the case of a position before I insert a new data element e, L, the length of 1
Int * newbase;
Int * p, * q;
If (i<1 | | i> L.l ength + 1)
Return the ERROR;
If (L.l ength>=L.l istsize)
{
Newbase=(ElemType *) realloc (L.e lem, (L.l istsize + LISTINCREMENT) * sizeof (ElemType));
if(! Newbase) exit (OVERFLOW);
L.e lem=newbase;
L.l istsize +=LISTINCREMENT;
}
Q=& amp; (L.e lem] [I - 1);
For (p=& amp; (L.e lem [L.l] ength - 1); p>=q; P -) * (p + 1)=* p;
* q=e;
L.l ength++;
return OK;
}

The Status ListDelete (SqList & amp; L, int I ElemType & amp; E)
{//remove the first I L data elements, and returns its value, e L the length of the minus 1
If (i<1 | | i> L.l ength)
Return the ERROR;
Int * p, * q;
Q=& amp; (L.e lem] [I - 1);
E=* q;
For (p=& amp; (L.e lem [L.l] ength - 1); p>=q; Q++) * (p=* p - 1);
L.l ength -;
return OK;
}

The Status visit (SqList L)
{//output sequential order table of each element value
int i;
for(i=1; I<=L.l ength; I++)
Printf (" % d ", * (L.e lem + I - 1));
CoutPrintf (" L.e lem=% u L.l ength=% d L.l istsize=% d \ n ", L.e lem, L.l ength, L.l istsize);
return OK;
}


Void main ()
{
SqList L;
ElemType e;
The Status of I;
Int j;
I=InitList (L);
Visit (L);
for(j=1; j<=5; J++)
I=ListInsert (L, 1, j);
Printf (" in the header of L in turn after the insertion of 1 ~ 5: * L.e lem=");
Visit (L);
for(j=1; j<=5; J++)
(L.e lem + L.l ength + j - 1)=j;
Printf (" at the end of L table in turn after the insertion of 1 ~ 5: * L.e lem=");
L.l ength=L.l ength + 5;
Visit (L);
ListInsert (L, 1, 0);
Printf (" in the L header after insert 0: * L.e lem=");
Visit (L);
I=LocateElem (L, 1);
Printf (" data elements of value is 1 position in the sequence table is ");
Printf (" % d ", I);
CoutGetElem (L, 5, e);
Printf (" the fifth element value is: % d \ n ", e);
Printf (" delete the third data elements in L: * L.e lem=");
ListDelete (L, 3, e);
Visit (L);
DestroyList (L);
Printf (" after the destruction of L: L.e lem=% u L.l ength=% d L.l istsize=% d \ n ", L.e lem, L.l ength, L.l istsize);
}

CodePudding user response:

Estimation is c does not support a reference type (c + + support)
The Status InitList (SqList & amp; L)//into a pointer type, SqList * L

CodePudding user response:

Your compiler error too much Suggestions according to the error of the IDE line by line

CodePudding user response:

Error: expected '; ', ', 'or') 'before' & amp; 'token
This error is usually in a row you forgotten; Or when an error

CodePudding user response:

Run into a similar problem is done with
/*... every time." */comment out different parts to recompile again, until orientation to the location of the specific grammatical errors, "
The methods to solve of,

CodePudding user response:

Suggest the landlord to confirm their own compiler, it is C or C + +, parameter, & amp; Is a c + + syntax rules, can try should * instead of & amp;

See the building there were cout
Code is copied, there are a few problems need to change,

//typedef ElemType; 
Typedef int ElemType;


//return OK 
return OK;


CodePudding user response:

reference 1st floor qybao response:
estimation is c does not support a reference type (c + + support)
The Status InitList (SqList & amp; L)//into a pointer type, SqList * L


He this estimate is to want to write C + + code, with the C just cout
  • Related