// 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) 
#include <iostream>
#include <string>

using namespace std;

static char retbuf[1000];

char *mid(char *s,int ix,int n)
{
   strncpy(retbuf,s+ix,n);
   retbuf[n] = '\0';
   return retbuf;
}

int main()
{
   char s1[] = "abcd";
   cout << mid(s1,1,2) << endl;
   string s2 = "efgh";
   cout << s2.substr(1,2) << endl;
   return 0;
}
