#include <string.h>
extern char *strcat(char *dest,char *src);

#############################

 

功 能:把一整数转换为字符串

该函数的头文件是"stdlib.h"

 

用 法:char *itoa(int value, char *string, int radix);   

################################################

#include <iom16v.h>
#include <macros.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "1602.c"
#define uchar unsigned char
#define uint unsigned int
#pragma interrupt_handler int0:2 //外部中断0
uchar table[]="LIUYUNQIAN";
uchar table1[15]="INT NUM:";
int i=0;
char str[5];  
void delay(uint ms)
{
   uint i,j;
for(i=0;i<ms;i++)
for(j=0;j<1141;j++);
}
void main()
{
  
init_1602();
DDRD|=BIT(2);
PORTD|=BIT(2);
   MCUCR=0X02;//INT0下降沿中断
GICR|=BIT(6);//int0使能
GIFR=0;//清除中断标?

SREG|=BIT(7);

//show_1602(table,table1);
// write_com(0x80+0x40+9);
//用 法:char *itoa(int value, char *string, int radix);

while(1)
{
  
  
//show_1602(table,str);
   show_1602(table,table1);
  
  
  
}
  

}

void int0()//中断标志。进入中
//断服务程序之后该中断标志自动清零。此外,标志位也可以通过写入”1” 来清零
{
     //uchar k;
   SREG&=~BIT(7);
  

str[0]='\0';
table1[8]='\0';
    
   i++;
itoa(str,i,10);
strcat(table1,str);//有这个程序出错啊
SREG|=BIT(7);
}

 

评论 avr外部中断。+1602 itoa strcat