2014-03-13 56 views
-1

我有一個變量名稱day = 3。我想在LCD打印爲03 .concept我試圖impliment是 如下加入兩個變量和LCD打印

int term1; 
int term2; 
int day=3; 
term1=day%10;// here i get the actual term day 
term2=(int)(day/10). here i get term 0. 

現在我想通過參加字詞1和字詞2 LCD上進行打印。這裏

lcd.print(concat(term1&term2) 

的問題是如何加入字詞1和2項得到的結果顯示爲03,而不是3

回答

0

試試這個。

lcd.print(term1); 
lcd.print(term2); 
0

您可以使用一個數組來存儲當天的值

char day_string[3]; 
int day; 
if (day < 10) 
{ 
    // prepend a 0 to day if day is one digit 
    day_string[0]='0'; 
    day_string[1]=day; 
    day_string[2]='\0'; 
    lcd.print(day_string); 
} 
else 
    // if day is a two digit value print itself 
    lcd.print(day);