该程序尝试从用户那里获取输入并将其存储在名为 2 的宏中,但是当我打印宏时,我得到 1 作为输出....为什么?
#include <stdio.h>
//declares two
int two;
//Takes input to store it in two
#define two scanf("%d",&two)
int main()
{
printf("%dn",two);
return 0;
}
您看到的是 scanf 返回的值。返回值是 scanf 成功填充的项目数(在本例中为 1 个项目(。请参阅此参考: http://www.cplusplus.com/reference/cstdio/scanf/