#define _GNU_SOURCE #include #include char *gcvt(double x, int n, char *b) { sprintf(b, "%.*g", n, x); return b; }