Code blocks MinGW and the %n conversion character

后端 未结 2 1478
萌比男神i
萌比男神i 2021-01-13 06:35

I am trying to use a conversion character to count the number of chars printed so far with the following code.

#include 
int main(void) {
             


        
2条回答
  •  爱一瞬间的悲伤
    2021-01-13 07:12

    It looks like this is a Windows issue, this article says:

    The default C-RunTime Library (msvcrt.dll) on Vista seems to have %n disabled by default - security reasons of course

    It looks like there is a _set_printf_count_output to enable it.

    BLUEPIXY found that in order to get it working outside Visual Studio you need to define __USE_MINGW_ANSI_STDIO:

    #define __USE_MINGW_ANSI_STDIO 1
    

提交回复
热议问题