word2char.c

来自「用C51单片机实现的MP3播放器的c代码程序。」· C语言 代码 · 共 53 行

C
53
字号
#ifndef _COMMON_DEFINE
 #include "COMMON.c"
#endif

void WORD2CHAR(WORD in,CHAR *out,BYTE l);
void WORD2CHAR(WORD in,CHAR *out,BYTE l)
{
	data BYTE temp,i;
	bit f=0;
	i=0;
	if (in>9999)
	{
	 	temp=in/10000;
		in-=(temp*10000);
		if (l>4) {out[i++]=temp+48;f=1;}
	}
	else
		if (l>4) out[i++] = f ? '0' : ' ';

	if (in>999)
	{
	 	temp=in/1000;
		in-=(temp*1000);
		if (l>3) {out[i++]=temp+48;f=1;}
		printf("%bd\n",i);
	}
	else
		if (l>3) out[i++] = f ? '0' : ' ';

	if (in>99)
	{
	 	temp=in/100;
		in-=(temp*100);
		if (l>2) {out[i++]=temp+48;f=1;}
	}
	else
		if (l>2) out[i++] = f ? '0' : ' ';

	if (in>9)
	{
	 	temp=in/10;
		in-=(temp*10);
		if (l>1) {out[i++]=temp+48;f=1;}
	}
	else
		if (l>1) out[i++] = f ? '0' : ' ';
	
	temp=in;
	out[i++]=temp+48;
	out[i]=0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?