tags:

views:

75

answers:

3

In C#, I can specify a fixed sized buffer using the fixed keyword, like so:

public unsafe struct StructWithFixedBuffer
{
    public fixed char FixedBuffer[128];
}

how would I express the same thing in C++/CLI?

A: 

Without the 'fixed' i think

tm1rbrt
+2  A: 

The C# syntax was added as a way to express the C++ syntax you've know forever. :)

public:
    wchar_t FixedBuffer[128];
280Z28
+1  A: 

Quote:

size of the 128 element char array is 256 bytes. Fixed size char buffers always take two bytes per character, regardless of the encoding.

So you want:

struct StructWithFixedBuffer
{
    char FixedBuffer[128*2];
};
Alok