pointer-math

Pointer math in C#

I am trying to use some pinvoke code to call a C function. The function fills a buffer with data. The structure is set up as a DWORD for the length, followed by a string. How do I extract the string from the IntPtr? IntPtr buffer = Marshal.AllocHGlobal(nRequiredSize); PInvokedFunction(buffer, nRequiredSize); string s = Marshal.Ptr...

C: Pointers and Arrays Question

I keep reading that, in C, using pointer arithmetic is generally faster than subscripting for array access. Is this true even with modern (supposedly-optimizing) compilers? If so, is this still the case as I begin to move away from learning C into Objective-C and Cocoa on Macs? (As is the primary goal of my picking up C -- get enough th...