#include<reg52.h>
#include<stdio.h>
#define uint unsigned int
#define uchar unsigned char
uchar ch[8];
sbit K1=P3^2;
void delayms(uint x)
{
while(x--)
{
uint i;
for(i=112;i>0;i--);
{;}
}
}
void uart(void)
{
SCON=0x40;
REN=1;
PCON=0;
TMOD=0x20;
TH1=0xfd;
TL1=0xfd;
TI=1;
TR1=1;
}
int main()
{
uchar ch[8];
uint j;
uart();
printf("please input the char and input ' 'to stop\n");
for(j=0;j<8;j++)
{
scanf("%c",&ch[j]);
if(ch[j]==' ')
break;
}
printf("\n");
printf("please press the K1 to display the word!\n");
while(K1!=0);
delayms(100);
if(K1==0)
{
while(K1==0);
printf("the char is {");
for(j=0;j<8;j++)
{
printf("%c",ch[j]);
}
printf("}\n\n\n");
}
}
请各位帮忙看一下为什么会出现乱码?