Anh ơi em viết hàm con hiển thị số dạng float ra màn hình cụ thể như sau :
Code:
void hienthi( float o, unsigned char a[15])
{
LCD_cmd4(LCD_homeL1); // ve dau dong thu 2
Delay_ms(100);
_PSV=1;
PSVPAG = __builtin_psvpage(a);
idx = 0;
Delay_ms(50);
while (a[idx]) { //Xuat chuoi ra dong thu nhat cua LCD
LCD_dat4(a[idx++]);
Delay_ms(1);}
//////// Doi kieu float sang char/////////
i=0;
l=0;
o=(o*1000)/10;
out=(long int)(o + 0.5);
ra=out;
while(out!=0)
{
in= (long int)( out%10);
out=(long int)(out/10);
i=i+1;
}
j=i-1;
for (k=i;k!=0;k--)
{
doi_mu(j);
in=(long int)(ra/mu);
ra=(long int)( ra%mu);
doi_asci(in);
s[l]=ch;
j--;
l++;
}
LCD_cmd4(LCD_homeL2); // ve dau dong thu 2
Delay_ms(100);
_PSV=1;
PSVPAG = __builtin_psvpage(s);
idx = 0;
Delay_ms(50);
while (s[idx]) { //Xuat chuoi ra dong thu nhat cua LCD
LCD_dat4(s[idx++]);
Delay_ms(1);}
}
ở hàm main em viết
Code:
int main()
{
init......
hienthi(t_dat,chuoi1);
}
Em viết như vậy nó báo lỗi thế này ( con trỏ báo lỗi ở cuối hàm hienthi()) .
Code:
C:\Documents and Settings\Lenovo\Desktop\lonhiet2.c:183: warning: passing argument 2 of 'hienthi' discards qualifiers from pointer target type
C:\Documents and Settings\Lenovo\Desktop\lonhiet2.c: In function 'hienthi':
C:\Documents and Settings\Lenovo\Desktop\lonhiet2.c:497: internal compiler error: in instantiate_virtual_regs_lossage, at function.c:1442
Còn khi em không viết hàm con hienthi() mà đua thẳng vào hàm main thì nó không báo lỗi nữa ( nếu đưa thẳng vào hàm main thì chương trình sẽ rất dài ) Em sửa từ sáng đến giờ không biết sai ở đâu. ánh giúp em với ( xin lỗi anh vì em mới học nên hỏi hơi nhiều )