小错误,该怎么改?
#include<iostream.h>typedef struct{
int *data;
int length;
}ST;
int creat(ST *t, int key){ //折半查找开始
int low,mid,high;
int flag;
low=1;
flag=0;
high=t->length;
while(low<=high){
mid=(low+high)/2;
if(key<t->data[mid])
high=mid-1;
else if(key>t->data[mid])
high=mid+1;
else
{flag=mid;
break;}
}
return flag;
}
void main(){
int a[]={1,2,3,4,5,6,7,8,9,11};
ST *p;
int f;
p->data=a; //错误
f=creat(p,3);
cout<<f;
}
错误提示:local variable 'p' used without having been initialized