Home > Back-end >  A question about beginner C
A question about beginner C

Time:10-04

S.b ase=(int *) realloc (S.b ase, (S.s tacksize + kuozhan) * sizeof (int));
At the beginning of the program wrote # include & lt; malloc.h> How still hint is wrong exactly wrong where!!!!!!!!!! Crying is fast

CodePudding user response:

What is wrong?

CodePudding user response:

No realloc. H header file but & lt; malloc.h> This header file
Compiling...
SDF. CPP
C: \ Users \ \ Administrator \ Desktop \ SDF CPP (21) : error C2143: syntax error: missing ') 'before'; '
C: \ Users \ \ Administrator \ Desktop \ SDF CPP (21) : error C2143: syntax error: missing ') 'before'; '
C: \ Users \ \ Administrator \ Desktop \ SDF CPP (21) : error C2059: syntax error: ')
C: \ Users \ \ Administrator \ Desktop \ SDF CPP (21) : error C2059: syntax error: ')
C: \ Users \ \ Administrator \ Desktop \ SDF CPP (21) : error C2100: illegal indirection
An error occurred when executing cl. Exe.
Both are sometimes so
SDF. CPP
C: \ Users \ \ Administrator \ Desktop \ SDF CPP (3) : fatal error C1083: always open include file: 'reamlloc. H: No to the file or directory
An error occurred when executing cl. Exe.

CodePudding user response:

Realloc function in the header file: & lt; Stdlib. H>

CodePudding user response:

Write stdlib. H is wrong to write realloc. H error is the same

CodePudding user response:

All of the code is the
#include
#include
#include
# define kuozhan 10;
Typedef struct {
Int * base;
Int * top;
Int stacksize;
} zhan.

Void init (zhan & amp; S)
{
S.b ase=(int *) malloc (sizeof (int));
S.t op=S.b ase;
}


Void push (zhan & amp; S, int e)
{
If (S.t op - S.b ase>=S.s tacksize)
{
S.b ase=(int *) realloc (S.b ase, (S.s tacksize + kuozhan) * sizeof (int));
}
* * * * * \ \ the asterisk represent some operating \ \
* S.t op++=e;
}

Pop (zhan is void & amp; S, int e)
{
While (S.t op) {
If (S.t op==S.b ase) break;
E=* - S.t op;
Printf (" % d ", e);
}
}

Void main ()
{
int i;
Zhan S;
Init (S);
Push (S, 5);
Pop (S, I);
}
  • Related