困惑于putchar结果在C

时间:2016-09-19 16:24:19

标签: c putchar

我对C中的putchar函数有疑问。在我学习期间,我偶然发现了以下声明: function customDirective() { return { scope: { model: '=' } link: function(scope) { scope.resetModel = function() { scope.model.name = null; //In these lines I was getting the above scope.model.email = null; //mentioned warning in webstorm. } } } } 当我编译并执行程序时,结果是BD。我不知道当我们输入function customDirective() { return { scope: { model:'<' // Please refer the above linked angular docs for in detail explanation. } link: function(scope) { scope.resetModel = function() { scope.model.name = null; scope.model.email = null; } } } } 时,结果将是B,但我们是如何获得D的?此函数不能一次返回一个字符吗? 提前致谢

1 个答案:

答案 0 :(得分:1)

putchar正在做两件事:

  1. 将字符“B”写入stdout
  2. 作为函数调用的结果返回char'B'。
  3. 由于{B}由putchar返回,因此它添加了2,使其成为'D'。这将作为参数传递给printf,然后将“D \ n”写入stdout

相关问题