C语言栈的有关问题,求大神帮解答

C语言栈的问题,求大神帮解答
题目是这个
---------------------------------------------------------------------------------------------------------------
编程实现顺序栈的初始化、入栈、出栈和计算栈中元素个数等基本操作。
Description
第一行为入栈元素; 出栈操作的次数
Input
第一行为入栈操作后栈中元素的个数; 第二行为元素出栈后,栈中元素的个数。
-----------------------------------------------------------------------------------------------------------------
然后这是我写的
#include<stdio.h>
#include<stdlib.h>
struct Data
{
int a;
struct Data *inData;
};

struct Data *top;

int main()
{
int b,x;
int shuru();
top = NULL;
x=shuru();
scanf("%d",&b);
printf("%d\n",x/2+1);
printf("%d\n",x/2+1-b);
return 0;
}

int shuru()
{
struct Data *newaddr;
char a;
int n;
n=0;
while(1)
{
scanf("%c",&a);
if(a=='\n')
return n;
else
{
newaddr=(struct Data *)malloc(sizeof(struct Data));
newaddr->a = a;
newaddr->inData = top;
top=newaddr;
n++;
}
}
}
a我用的char,然后现在一位数可以判断,但是有两位数的就错了,我把a改成int型然后if(a=='\n')就不能结束循环,这题应该怎么写呢?求帮助!
------解决思路----------------------
用一个特定的整数指示结束,比如-999。 

  if (a == -999) 
         ......
------解决思路----------------------
a为char类型的时候可以用EOF来结束循环。
while((a=getchar())!=EOF)
//循环体。
;

用ctrl+Z可以输入EOF字符