请问如何在屏幕上输出一个float数值,谢谢。

0

请问如何在屏幕上输出一个float数值,谢谢。

ava
B0pass

2020-3-21

1
#include <graphics.h>
#include <stdio.h>
#include <conio.h>

int main()
{
	initgraph(400, 600);

	TCHAR s[5];
	_stprintf_s(s, _T("%.2f"), 2.364);	// 0.2 保留两位小数
	outtextxy(10, 60, s);

	_getch();
	closegraph();
	return 0;
}
ava
xiongfj ◑◑

2020-3-21

技术讨论社区