문제

C Language:

BASIC has print ? myVar that bundles up the variable name & value. Available in C? I'm using a flavor of C for microcontrollers Thanks

도움이 되었습니까?

해결책

You can define a macro:

#define PR_INT(x) printf(#x"=%d\n",x)
#define PR_CHAR(x) printf(#x"=%c\n",x)
#define PR_STRING(x) printf(#x"=%s\n",x)

and so on

There is no such feature built into the language because the variable name is just a label,which the compiler may not need after the parsing stage (still needs the global variables)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top