void fun()
{
// What goes here?
}
void main()
{
int x = 20;
fun();
x = 10;
printf("%d",x); // Should print 20.
}
这是我的测试问题之一。我想知道是否应该使用static int
。你能帮我吗?
最佳答案
我不容忍这种做法,这是一个可怕的想法。但从技术上讲,这在某种程度上符合问题的标准。
void fun()
{
// Essentially this is a function with an empty body
// And I don't care about () in a macro
// Because this is evil, regardless
#define printf(a, b) (printf)(a, b*2)
}
void main() // I know this is not a valid main() signature
{
int x = 20;
fun();
x = 10;
printf("%d", x);
}
关于C 访谈输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38156503/