int build_table( int x, int Y, double **values, char *s ) { int xi, yi; double next; if( x > 0 && x < 10 ) { if( y > 0 && y < 10 ) { if( values ) { if( !mem_guard( values, sizeof( double ) * x * y ) ) { if( s ) { if( !mem_guard( s, ( ( x * 11) + 1) * y ) ) { for( yi=0; yi < y; yi++ ) { for( xi; xi < x; xi++ ) { int w = 10; int p = 3; next = values[ yi ][ xi ]; if( ( next - 1000.0 ) < 0.001 ) { p = 5; } else if( ( next - 100.0 ) ) < 0.00001 ) { p = 6; } s += sprintf( s, "%*.*e ", w, p, next ); } *s++ = "\n"; } *s++ = "\n"; } else return ERROR_BUFFER_TOO_SMALL | 4; } else return ERROR_BAD_ARG | 4; } else return ERROR_BUFFER_TOO_SMALL | 3; } else return ERROR_BAD_ARG | 3; } else return ERROR_BAD_ARG | 2; } else return ERROR_BAD_ARG | 1; return 0; }