Home > Back-end >  Fatal error C1004: unexpected end of file is found
Fatal error C1004: unexpected end of file is found

Time:09-21

A fatal error C1004: unexpected end of file found
My source code is as follows:
# include
# include
# include
# define null 0
# define OK 1
Typedef int elemtype;
Typedef struct StackNode
{
Elemtype data;
StackNode * next;
StackNode * top;
} LinkStack;
Void initStack (LinkStack * S)
{
S - & gt; Top=null;
}
Void setempty (LinkStack * S)
{
S - & gt; Top=null;
}
Void pushStack LinkStack * S, elemtype (x)
{
LinkStack * p;
P=(LinkStack *) malloc (sizeof (LinkStack));
p-> data=https://bbs.csdn.net/topics/x;
p-> Next=S;
S=p;
}
Elemtype popStack (LinkStack * S)
{
If (S==null)
{
Printf (" this stack is empty!" );
Return (null);
}
The else
{
LinkStack * p=S;
S=S - & gt; next;
free(p);
return OK;
}
}
Elemtype Stacktop (LinkStack * S)
{
If (S - & gt; Top==0)
{
Printf (" \ n chain stack is empty! \n");
exit(-1);
}
}
Void disp (LinkStack * S)
{
Printf (" \ n chain data in a stack for: \ n ");
Printf ("==============================");
StackNode * p;
P=S - & gt; Top;
While (p!=null)
{
Printf (" % d \ n ", p - & gt; data);
P=p - & gt; next;
}
Printf ("==============================");
}
Void main ()
{
Printf ("======chain stack operation========");
Int I, m, n, a;
LinkStack * S;
S=(LinkStack *) malloc (sizeof (LinkStack));
Int cord;
Do
{
Printf (" \ n use for the first time you must initialize the \ n \ n \ n \ n \ n1 main menu chain of initialization stack \ n ");
Printf (" \ \ n \ n3 n2 into the stack out of the stack \ n \ \ n \ n5 n4 interchange take stack elements chain of empty stack \ n \ n \ n \ n6 end program is run ");
Printf (" \ n -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
Printf (" please enter your choice (6) \ n ");
The scanf (" % d ", & amp; Cord);
printf("\n");
The switch (cord)
{
Case 1: {initStack (S); Disp (S);
} break;
Case 2: {printf (" input will pressure into the number of data in a stack: n=");
The scanf (" % d ", & amp; N);
Printf (" % d a data in turn pressure into the stack: \ n ", n);
for(i=1; I<=n; I++)
{the scanf (" % d ", & amp; A);
PushStack (S, a);
}
Disp (S);
}break;
Case 3: {printf (" \ n the stack operation started \ n ");
Printf (" input to the number of the stack: m=");
The scanf (" % d ", & amp; M);
for(i=1; I<=m; I++) {printf (" \ n the first % d times the stack data is: % d \ n ", I, popStack (S));
}
break;
}
Case 4: {printf (" \ n \ n elements on the top of the stack is: % d \ n ", Stacktop (S));
}break;
Case 5: {setempty (S);
Disp (S);
}break;
Case 6: {exit (0);
break;
}
}
}

CodePudding user response:

Behind your pai function is missing a}
  • Related