from ctypes import cdll libc = cdll.msvcrt message = "hello world!\n" length = libc.printf("printing msvcrt: %s", message) print length
the result of code above:
33 printing msvcrt: hello world!
why length of string printed first, rather string itself?
you using 2 separate instances of c runtime libraries. msvcrt.dll
, whatever version python linked to. python 2.7 version uses msvcr90.dll
, visual studio 2008.
this means there 2 separate instances of buffered stdout, , in case python's buffered i/o flushing before other instance. not reproduce output of script.
Comments
Post a Comment