c++ - Why does my function print '0'? -
here code, don't know why happen:
#include <stdio.h> void foo(float *); int main() { int = 10, *p = &i; foo(&i); } void foo(float *p) { printf("%f\n", *p); }
output :
0
you calling function expecting float*
pointer int. in c++ error , code not compile. in c warning , undefined behaviour anyway.
Comments
Post a Comment