Python Forum
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DLL printf not working
#1
I have just installed python 3.6 (32-bit), eclipse, and PyDev. I am going through the Gray Hat Python book (which uses 2.5) and cannot get the dll call for printf to work properly. I have tried to find a solution to no avail.

The code is as follows. It will only print the first character of the output string to the console.

from ctypes import *

msvcrt = cdll.msvcrt
msvcrt.printf

message_string = "Hello World!\n"
msvcrt.printf("Testing: %s", message_string)

Output:
T
Reply
#2
I get the same result - You should report it to python.org as a bug

This doesn't work in any python 3 version (I tried 3 of them)
I am guessing that it might not be a bug, but have to do with text automatically being utf-8
in python. See http://stackoverflow.com/questions/84529...lue-python
Reply
#3
(Jan-02-2017, 05:21 AM)Larz60+ Wrote: I get the same result - You should report it to python.org as a bug

This doesn't work in any python 3 version (I tried 3 of them)
I am guessing that it might not be a bug, but have to do with text automatically being utf-8
in python. See http://stackoverflow.com/questions/84529...lue-python


I just installed Python 2.7 and ran the same code and I got the expected results. I will send a message as you suggested.
Reply
#4
Quote:
Quote:I am guessing that it might not be a bug, but have to do with text automatically being utf-8

in python
I just installed Python 2.7 and ran the same code and I got the expected results. I will send a message as you suggested.


Don't think it's a bug
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020