C 访谈输出

标签 c output

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/

相关文章:

C——操作指针

c - 使用 i2c 总线访问驱动程序时出现未知核心转储

c - C 中的 strtok 函数

java - 为什么将行分割成数组后,for循环后的代码不起作用?

output - 使用 ToString 将数字转换为字符串时,如何停止 Mathematica 对数字的最后一位进行舍入?

c - 这段代码中的不透明是什么?

c - 指针分配警告

c - char* 究竟定义了什么?如果它定义了一个字符串数组,我如何输出单个元素?

python - 函数输出为整数(TypeError : must be str, 不是 int)

java - 如果用户使用键盘输入错误,如何再次调用该类