关于函数指针被赋值时候 右值与左值不一样的问题
详细描述在代码注释中
#include "stdio.h"
typedef int (*PNFV)() ;
int temp1()
{
return printf( "temp1\n" );
}
int temp2()
{
return printf( "temp2\n" );
}
int temp()
{
static PNFV temp = 0;
if ( temp == 0 )
{
temp = temp1; \\此处不管是 temp=&temp1 还是temp = \\ = temp1,temp的值都是一样,但跟temp1不同?何解??
temp();
}
else if ( temp == temp1 )
{
temp = &temp2;
\\同上;
temp();
}
return 0;
}
int main()
{
printf( "The address of temp1 is %x\n", temp1 );
printf( "The address of temp2 is %x\n", temp2 );
temp();
printf( "The address of temp is %x\n", temp );
temp();
printf( "The address of temp is %x\n", temp );
return 0;
}