求解,为什么会运行错误??
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <conio.h>
#define R 10
typedef struct
{
char name[10];
char sex[4];
char age[4];
char Tel[14];
char qins[5];
char cla[14];
}IM;
IM st[R]={{"r","m","18","15200860466","225","0901"}};
int search(IM q,int n,IM *st)//找出要删去的信息是否存在
{
int i=0;
IM *p;
p=st;
while(n!=0)
{
if(strcmp(q.name,p->name)==0)
{
return i;
break;
}
i++;
p++;
n--;
}
if(n==0&&i!=0)
{
printf("there is not a student.\n");
return -1;
}
}
void con(int i,int n,IM *st)//删去信息
{
for(;i<n;i++)
{
strcpy((st+i)->name,(st+i+1)->name);
strcpy((st+i)->age,(st+i+1)->age);
strcpy((st+i)->sex,(st+i+1)->sex);
strcpy((st+i)->Tel,(st+i+1)->Tel);
strcpy((st+i)->cla,(st+i+1)->cla);
strcpy((st+i)->qins,(st+i+1)->qins);
}
}
void main()
{
int search(IM q,int n,IM *st);
void con(int i,int n,IM *st);
int n=4;
//删去信息过程
int i,b=1;
while(b==1)
{
IM q;
system("cls");
printf("********************************************************************************\n\n\n");
printf("\t\t\t 删除界面\t\t\t\n\n");
printf("\t\t\t|-----------------------------------|\n");
printf("\t\t\t| |\n");
printf("\t\t\t| |\n");
printf("\t\t\t| |\n");
printf("\t\t\t| 请输入要删除的姓名: |\n");
printf("\t\t\t| |\n");
printf("\t\t\t| Tips: |\n");
printf("\t\t\t| 一旦删除,就不能恢复! |\n");
printf("\t\t\t| |\n");
printf("\t\t\t|-----------------------------------|\n");
gotoxy(46, 10);
scanf("%s",&q.name);
i=search(q,n,st);
if(i!=-1)
{
con(i,n,st);
n--;
}
printf("\n 如果你想继续删除,请输入 1,否则请输入 2\n");
scanf("%d",&b);
}
}