Home > Back-end >  C language data structure C2143 error for great god answer!
C language data structure C2143 error for great god answer!

Time:12-08

# include "stdio.h"
# include "stdlib. H"
//# include & lt; Stdbool. H>
100//# define Maxsize definition stack the maximum capacity of the
Typedef int Datatype.
Typedef struct
{Datatype data [Maxsize];//define the storage stack elements of the array, defining element in the stack, Datatype as elements of the data type
Int top;//define the stack pointer to the top of the stack
} Sqstack;
Void initstack (Sqstack * & amp; L)/* stack initialization order */
{L=(Sqstack *) malloc (sizeof (Sqstack));
L - & gt; Top=1;//initialize the stack pointer top to 1, the stack is empty
}
Int stackempty (Sqstack * L)/* whether order the stack is empty */
{
Return (L - & gt; Top=1);
}
Void main ()
{
Sqstack s;
Printf (" (1). Initialize the stack sequence; \n");
Initstack (s);

Printf (" (2). Whether order the stack is empty: ");
If (stackempty (s))
{
Printf (" this is an empty stack order. \n");
}
The else printf (" this is an empty stack order. \n");
}


K: \ data structure (C language) \ \ order stack \ new text documents. C (12) : error C2143: syntax error: missing ') 'before' & amp; '
K: \ data structure (C language) \ \ order stack \ new text documents. C (12) : error C2143: syntax error: missing '{' before' & amp; '
K: \ data structure (C language) \ \ order stack \ new text documents. C (12) : error C2059: syntax error: '& amp; '
K: \ data structure (C language) \ \ order stack \ new text documents. C (12) : error C2059: syntax error: ')
K: \ data structure (C language) \ \ order stack \ new text documents. C (43) : warning C4013: 'initstack undefined; Assuming extern returning int
K: \ data structure (C language) \ \ order stack \ new text documents. C (46) : error C2115: 'function: incompatible types
K: \ data structure (C language) \ \ order stack \ new text documents. C (46) : warning C4024: 'stackempty' : the company types for formal and actual parameter 1
An error occurred when executing cl. Exe.


CodePudding user response:

The parameters of the function prototype is a pointer type, the main function of s is not a pointer

CodePudding user response:

 # include "stdio.h" 
# include "stdlib. H"
//# include & lt; Stdbool. H>
100//# define Maxsize definition stack the maximum capacity of the

Typedef int Datatype.
Typedef struct
{
Datatype data [Maxsize];//define the storage stack elements of the array, defining element in the stack, Datatype as elements of the data type
Int top;//define the stack pointer to the top of the stack
} Sqstack;
Void initstack (Sqstack * & amp; L)/* stack initialization order */
{
L=(Sqstack *) malloc (sizeof (Sqstack));
L - & gt; Top=1;//initialize the stack pointer top to 1, the stack is empty
}
Int stackempty (Sqstack * L)/* whether order the stack is empty */
{
//return (L - & gt; Top=1);
Return (L - & gt; Top==1);
}
//void main ()
Int main ()
{
//Sqstack s;
Sqstack * s;
Printf (" (1). Initialize the stack sequence; \n");
Initstack (s);

Printf (" (2). Whether order the stack is empty: ");
If (stackempty (s))
{
Printf (" this is an empty stack order. \n");
}
The else printf (" this is an empty stack order. \n");
}

For your reference ~

CodePudding user response:

Void initstack (Sqstack * & amp; L)
The asterisk and & amp; Ed?

CodePudding user response:

reference 1st floor qq_45798109 response:
function prototype of the parameter is a pointer type, the main function of s is not a pointer

Hello, I changed the place but still doesn't work,

CodePudding user response:

reference 2 building self-confidence boy reply:
 # include "stdio.h" 
# include "stdlib. H"
//# include & lt; Stdbool. H>
100//# define Maxsize definition stack the maximum capacity of the

Typedef int Datatype.
Typedef struct
{
Datatype data [Maxsize];//define the storage stack elements of the array, defining element in the stack, Datatype as elements of the data type
Int top;//define the stack pointer to the top of the stack
} Sqstack;
Void initstack (Sqstack * & amp; L)/* stack initialization order */
{
L=(Sqstack *) malloc (sizeof (Sqstack));
L - & gt; Top=1;//initialize the stack pointer top to 1, the stack is empty
}
Int stackempty (Sqstack * L)/* whether order the stack is empty */
{
//return (L - & gt; Top=1);
Return (L - & gt; Top==1);
}
//void main ()
Int main ()
{
//Sqstack s;
Sqstack * s;
Printf (" (1). Initialize the stack sequence; \n");
Initstack (s);

Printf (" (2). Whether order the stack is empty: ");
If (stackempty (s))
{
Printf (" this is an empty stack order. \n");
}
The else printf (" this is an empty stack order. \n");
}

For reference ~

Hello, I use after you change the code or useless,

CodePudding user response:

The
reference 3 floor proorck2019 response:
void initstack (Sqstack * & amp; L)
The asterisk and & amp; Ed?

Uh huh, do it no problem before,

CodePudding user response:

references 4 building dish dish beginner's reply:
Quote: refer to 1st floor qq_45798109 response:
function prototype of the parameter is a pointer type, the main function of s is not a pointer

Hello, I changed the place but still useless,

Sqstack s; To Sqstack * s; My clouds out ah, although I don't know whether the result you want

CodePudding user response:

refer to 7th floor qq_45798109 response:
Quote: dish dish beginners reference 4 floor response:
Quote: refer to 1st floor qq_45798109 response:
the parameters of the function prototype is a pointer type, the main function of s is not a pointer

Hello, I changed the place but still useless,

Sqstack s; To Sqstack * s; My clouds out ah, although I don't know whether the result you want

Hello, you have a look at my new hair stick, a string can run to compile the code, but I couldn't compare the mistake,

CodePudding user response:

nullnullnullnullnullnullnullnullnullnull
  • Related