_set_printf_count_output()在Windows 7下出现故障

fxnxkyjh  于 2023-04-11  发布在  Windows
关注(0)|答案(1)|浏览(115)

微软在他们无限血腥的智慧中默认禁用了printf中的%n说明符(及其所有变体)。
您可以使用此功能重新启用它;_set_printf_count_output()。
我用过这个--在过去的一段时间里--而且很有效。
现在它不工作了。平台是Windows 7上的最新SDK。
还有人发现这个吗

a0zr77ik

a0zr77ik1#

项目:

int _tmain(int argc, _TCHAR* argv[])
{
    int count;
    _set_printf_count_output(1);
    printf( "1234567890123456%n78901234567890\n", &count);
    printf("%d\n", count);
    return 0;
}

输出:

123456789012345678901234567890
16

(来源:typepad.com

相关问题