I'm guessing at the answer here because I'm on vacation with no access to a pc 
of any kind let alone Windows. But are you running python inside an ide? If so 
you might find you get the expected result if you use a command prompt, since 
printf usually sends output to stdout.

This is another example of the rule that you should never mix display and 
logic. If the dll returned the string instead of printing it you could display 
it from python easily, but by using print you make your code dependant on a 
stdout being visible.

Hth

Alan g


On 8 May 2018, at 23:03, Brad M <thebigwu...@gmail.com> wrote:

Hi all:

I am trying out some c based module in a .dll file on windows.

// helloworld.c
#include <stdio.h>

__declspec(dllexport) void helloworld()
{
    printf("Hello Everyone!!!");
}

I compile this by typing this in the command line:

cl /LD /I C:\python\include helloworld.c C:\python\libs\python36.lib

I get helloworld.dll for the above.



and the following is the python caller

import ctypes
mydll = ctypes.CDLL('helloworld')
mydll.helloworld()



However, this doesn't print anything on the python window.
What I would like is to do is to be able to use printf() in my .dll
by having the c code pop up a console window to print or
to have something that can print() in the python window somehow.

Is this possible?

Thanks!
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to