
Hi, Suppose I have a value of type Ptr Word8 and also an Int which is the length of the Ptr Word8(sorry if I am thinking too much in a C string frame of mind). How can I display the Ptr Word8 value of the given length? Vasili

2008/6/28 Galchin, Vasili
Hi,
Suppose I have a value of type Ptr Word8 and also an Int which is the length of the Ptr Word8(sorry if I am thinking too much in a C string frame of mind). How can I display the Ptr Word8 value of the given length?
Vasili
You're best bet would be to use 'peekArray' or 'withArrayLen' to get a list of Word8 values, and then display that however you want. withArrayLen: http://haskell.org/ghc/docs/latest/html/libraries/base/Foreign-Marshal-Array... peekArray: http://haskell.org/ghc/docs/latest/html/libraries/base/Foreign-Marshal-Array... I hope that helps! -Antoine

2008/6/28 Galchin, Vasili
Hi,
Suppose I have a value of type Ptr Word8 and also an Int which is the length of the Ptr Word8(sorry if I am thinking too much in a C string frame of mind). How can I display the Ptr Word8 value of the given length?
You mentioned C style strings - if you need to interface with foreign libraries which are expecting/providing actual C strings, you may also want to look at the Foreign.C.String module: http://haskell.org/ghc/docs/latest/html/libraries/base/Foreign-C-String.html -Antoine
participants (2)
-
Antoine Latter
-
Galchin, Vasili