开发者

_set_printf_count_output() appears broken under Windows 7

开发者 https://www.devze.com 2023-02-11 18:49 出处:网络
Microsoft in their infinite bloody wisdom have by default disabled the %n specifier in printf (and all variants thereof).

Microsoft in their infinite bloody wisdom have by default disabled the %n specifier in printf (and all variants thereof).

You can re-enable it with this function; _set_printf_count_output().

I have used this - some time ago in the past - and it worked.

Now it isn't working. Platform is latest SDK on Windows 7.

Anyo开发者_开发百科ne else finding this?


Program:

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

Output:

123456789012345678901234567890
16

0

精彩评论

暂无评论...
验证码 换一张
取 消