// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Runtime.InteropServices; namespace PtrTyp { public class Program { [DllImport("msvcrt.dll")] public static extern IntPtr calloc(int numelm, int elmlen); [DllImport("msvcrt.dll")] public static extern void memset(IntPtr p, int val, int len); [DllImport("msvcrt.dll")] public static extern int printf(string fmt, IntPtr p); [DllImport("msvcrt.dll")] public static extern void free(IntPtr p); public static void Main(string[] args) { IntPtr p = calloc(1, 4); memset(p, 65, 3); printf("%s\n", p); free(p); } } }