1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] python ctypes: reading a string array

Discussão em 'Python' iniciado por Stack, Fevereiro 8, 2025.

  1. Stack

    Stack Membro Participativo

    With python ctypes, how can I read a NUL-terminated array of NUL-terminated strings, e.g. ghostscript's gs_error_names ?

    I know how to get the first value:

    from ctypes import *
    from ctypes.util import find_library

    gs = CDLL(find_library("gs"))
    print(c_char_p.in_dll(gs, 'gs_error_names').value)


    I also know how to get a fixed number of values:

    print(list((c_char_p * 10).in_dll(gs, 'gs_error_names')))


    But how can I read all values until the end of the array?

    Continue reading...

Compartilhe esta Página