On this page
ctypes.c_char_p
Prev: ctypes.c_char | Up: ctypes | Next: ctypes.c_double
Rel: ctypes.addressof, ctypes.alignment, ctypes.ArgumentError, ctypes.Array
Ref: docs.python.org — ctypes.c_char_p
Tags: #public #python3 #stdlib #ctypes
Import
import ctypes
from ctypes import c_char_p
Signature & Overview
ctypes.c_char_p(...)
ctypes.c_char_p class.
Methods & Attributes
c_char_p.from_param(value, /)—c_char_p.from_parammethod/property.
Usage
import ctypes
p = ctypes.c_char_p(b"hello")
assert p.value == b"hello"
Gotchas
- Immutable NUL-terminated C string: Never pass
c_char_pto a C function that writes into the buffer—usecreate_string_buffer()instead.
REPL Inspect
from ctypes import c_char_p
help(c_char_p)
Linked from
Related notes
- tuts/python3/stdlib_module/ctypes/c_char Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/c_double Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/ctypes/addressof Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/alignment Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/ArgumentError Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/Array Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/BigEndianStructure shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/BigEndianUnion shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/byref shared tags: #ctypes, #stdlib