/* 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 <stdio.h>

static char buf[26];

char *qtoa(_int64 v)
{
   _int64 tmp;
   int ix,i;
   char c;
   if(v==0) {
      strcpy(buf,"0");
      return buf;
   }
   ix = 0;
   tmp = (v > 0) ? v : -v;
   while(tmp > 0) {
       buf[ix] = '0' + tmp % 10;
       ix++;
       tmp = tmp / 10;
   }
   if(v<0) {
      buf[ix]='-';
      ix++;
   }
   for(i=0;i<ix/2;i++) {
      c=buf[i];
      buf[i]=buf[ix-i-1];
      buf[ix-i-1]=c;
   }
   buf[ix]='\0';
   return buf;
}

int main()
{
   _int64 a = 1234567890L;
   a = 1000 * a;
   printf("%ld\n",a);
   printf("%s\n",qtoa(a));
   printf("%I64d\n",a);
   a = -1 * a;
   printf("%ld\n",a);
   printf("%s\n",qtoa(a));
   printf("%I64d\n",a);
}
