hanshen
Junior Member level 1
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 #include <stdio.h> #define INIT_SUM(a,b,c) \ struct test _test_struct = {(a),(b),(c)}; typedef void (*sum)(unsigned char a, unsigned char b); struct test{ unsigned char x; unsigned char y; sum ptr_sum; }; void summing(unsigned char w, unsigned char e); int main(){ INIT_SUM(0,0,summing) if(_test_struct.ptr_sum) _test_struct.ptr_sum(6,8); while(!getchar()); } void summing(unsigned char w,unsigned char e){ printf("answer is %d",w+e); }
In the statment "if(_test_struct.ptr_sum)", why the IF statement is true for the statement " _test_struct.ptr_sum(6,8);" is executed?