能不能帮我看一下这个线性表的插入函数到底是哪有问题

#include
#include
#include
#include

struct array
{
int * pBase;
int len;//数组长度
int cnt;//元素的有效个数
};

void init_array(struct array *p,int length);//初始化
void show_array(struct array *out);//输出
bool append_array(struct array *add,int val);//追加,val是追加的值
bool insert_array(struct array *p,int pos,int val);//在pos前插入val
bool full_array(struct array *p);//判断是否为满
bool is_empty(struct array *p);//判断是否为空

int main()
{
int val;
struct array ar1;
init_array(&ar1, 5);
append_array(&ar1, 3);//加入第一个元素
append_array(&ar1, 2);//第二个元素
append_array(&ar1, -2);//第三个
if(append_array(&ar1, 8))//第四个
printf("追加成功\n");
else
printf("追加失败\n");
if(insert_array(&ar1, 1, 99))
{
printf("插入成功\n");
}
else
printf("插入失败\n");
show_array(&ar1);
return 0;
}

void init_array(struct array *p,int length)
{
p->pBase = (int *)malloc(sizeof(int)*length);
if(NULL == p->pBase)
{
printf("动态内存分配失败\n");
exit(-1);//终止程序
}
else
{
p->cnt = 0;
p->len = length;
}
return;
}

bool full_array(struct array *p)
{
if(p->cnt == p->len)
return true;
else
return false;
}

bool is_empty(struct array *p)
{
if(0 == p->cnt)
return true;
else
return false;
}

bool append_array(struct array *add,int val)
{
if( full_array(add) )
return false;//满了就不追加
else
add->pBase[add->cnt] = val;
(add->cnt)++;
return true;
}

bool insert_array(struct array *p,int pos,int val)
{
int i;
if(full_array(p))
return false;
p->pBase[pos-1] = val;
for(i=p->cnt-1; i>pos-1; i--)
{
p->pBase[i+1] = p->pBase[i];
}
p->pBase[pos-1] = val;
( p->cnt)++;
return true;
}

bool delete_array(struct array *p,int pos,int *val)
{
int i;
for(i=pos; icnt; i++)
{
p->pBase[i-1] = p->pBase[i];
}
p->cnt--;
return true;
}

void show_array(struct array *out)
{
int i;
if( is_empty(out) )
{
printf("数组为空,请赋值");
}
else
{
for(i=0;icnt;i++)
printf("%-5d",out->pBase[i]);
}
}

是这样的,我这个程序运行结束以后输出的是
追加成功
插入成功
99 2 2 -2 8
为什么插入99以后原来的第一个元素3不见了?????

还有第二个问题:
bool insert_array(struct array *p,int pos,int val)
{
int i;
if(full_array(p))
return false;
if(posp->cnt+1)//为什么我加上这一个语句,这个函数就一直在输出插入失败,无论我pos输入多少都说我插入失败
return false;
p->pBase[pos-1] = val;
for(i=p->cnt-1; i>pos-1; i--)
{
p->pBase[i+1] = p->pBase[i];
}
p->pBase[pos-1] = val;
( p->cnt)++;
return true;
}

希望能告诉我原因,谢谢!!!!!

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 以帮助更多的人 ^-^