我在c中遇到了一个程序:
int bags[5]={20,5,20,3,20};
int main()
{
int pos=5,*next();
*next()=pos; //problem with this line(should give error :lvalue required)
printf("%d %d %d",pos,*next(),bags[0]);
return 0;
}
int *next()
{
int i;
for(i=0;i<5;i++)
if(bags[i]==20)
return (bags+i);
printf("error");
exit(0);
}
程序的输出是 5 20 5 虽然我预计它是需要的左值。谁能说出原因???