指针的初始化问题内存不能读,为什么啊
#include<stdio.h>#include<string.h>
int search(char*p[],char*name);
char*names[]={
"help",
"rex",
"dennis",
"john",
"NULL"};
void main()
{
if(search(names,"help")!=-1)
printf("help is list.\n");
if(search(names,"zhou")==-1)
printf("zhou is not found.\n");
}
int search(char*p[],char*name)
{
register int t;
for(t==0;p[t];++t)
if(!strcmp(p[t],name))
return t;
return -1;
}