[ctypes-users] Problems with ctypes helper function memset
Brought to you by:
theller
From: Srijit K. B. <sr...@ya...> - 2005-03-30 08:39:28
|
Hello, I am getting errors while using memset. Even cdll.msvcrt.memset is giving unexpected answer. I guess that I am doing something incorrect. The details are mentioned below. Best regards, /Srijit Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from ctypes import * >>> p = create_string_buffer("Hello", 10) >>> p.raw 'Hello\x00\x00\x00\x00\x00' >>> p.value 'Hello' >>> memset(p, "y", 3) Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: an integer is required >>> a = addressof(p) >>> a 10633040 >>> memset(a, "y", 3) Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: an integer is required >>> p.value 'Hello' >>> p.raw 'Hello\x00\x00\x00\x00\x00' >>> cdll.msvcrt.memset(a, "y", 3) 10633040 >>> p.value '\x14\x14\x14lo' >>> cdll.msvcrt.memset(p, "z", 3) 10633040 >>> p.value 'TTTlo' >>> p.raw 'TTTlo\x00\x00\x00\x00\x00' >>> __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ |