开发者

ruby equivalent of a c buffer

I am working on a small script using the USB bindings for ruby.

Since this is just a wrapper around libusb, all of C++'s features are visible through the abstraction, for example when usb_bulk_read requires giving a buffer as an argument (which would just be a pointer in C).

How can I create a buffer which is 64bytes long, for the following bit of code, without having to create a string with 64 spaces in coded into the program (which I am doing ATM). I wish ruby had pointers for this!

data =  "          "; /#etc. You get the idea
handle.usb开发者_如何学Python_bulk_read(1, data, 0)

Where handle is a USB::DevHandle object which has already been opened.


Simple answer that probably avoids the core issue:

data = ' ' * 64
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜