Is there a method by which I can view c function printf log out?

Issue #388 resolved
Jinjie Zhang
created an issue

I use cffi to call c function in python. But I can't view c function printf output.


#include <stdio.h>
int test_output(int n) {
    printf("log %d", n);

from cffi import FFI
ffi = FFI()
int test_output(int n);
ffi.set_source('pytest', '''
#include "test.h"
''', sources=['test.c'])
if __name__ == '__main__':

test code:

from pytest import lib, ffi

The code line lib.test_output(10) has no output.

Comments (3)

  1. Jinjie Zhang reporter

    I know the reason. printf format needs a '\n' newline. I change test_output to the following, It will work:

    int test_output(int n) {
        print("log %d\n", n);
  2. Log in to comment