函数原型: unsigned int _set_output_format( unsigned int format);
所属库: stdio.h
函数功能: 按指定的格式输出。
返回值: 返回之前的输出格式。
相关函数: _get_output_format、_set_printf_count_output
IDE: VS系列
下面这段代码来自MSDN
#include <stdio.h>
void printvalues(double x, double y)
{
printf("%11.4e %11.4e\", x, y);
printf("%11.4E %11.4E\", x, y);
printf("%11.4g %11.4g\", x, y);
printf("%11.4G %11.4G\", x, y);
putchar('\');
}
int main()
{
double x = 1.211E-5;
double y = 2.3056E-112;
unsigned int old_exponent_format;
printvalues(x, y);
old_exponent_format = _set_output_format(_TWO_DIGIT_EXPONENT);
printvalues(x, y);
_set_output_format( old_exponent_format );
printvalues(x, y);
return 0;
}
输出:
1.2110e-005 2.3056e-112
1.2110E-005 2.3056E-112
1.211e-005 2.306e-112
1.211E-005 2.306E-112
1.2110e-05 2.3056e-112
1.2110E-05 2.3056E-112
1.211e-05 2.306e-112
1.211E-05 2.306E-112
1.2110e-005 2.3056e-112
1.2110E-005 2.3056E-112
1.211e-005 2.306e-112
1.211E-005 2.306E-112
请按任意键继续. . .