A PROGRAM TO CONVERT INT INTO ASCII.
#include<stdio.h>
#include<string.h>
#include<conio.h>
char data[1000]= {' '}; /*thing in the bracket is optional*/
char data1[1000]={' '};
int val, a;
char varray [9];
void binary (int digit)
{
if(digit==0)
val=48;
if(digit==1)
val=49;
if(digit==2)
val=50;
if(digit==3)
val=51;
if(digit==4)
val=52;
if(digit==5)
val=53;
if(digit==6)
val=54;
if(digit==7)
val=55;
if(digit==8)
val=56;
if(digit==9)
val=57;
a=0;
while(val!=0)
{
if(val%2==0)
{
varray[a]= '0';
}
else
varray[a]='1';
val=val/2;
a++;
}
while(a!=7)
{
varray[a]='0';
a++;
}
varray [8] = NULL;
strrev (varray);
strcpy (data1,varray);
strcat (data1,data);
strcpy (data,data1);
}
void main()
{
int num;
clrscr();
printf("enter number\n");
scanf("%d",&num);
if(num==0)
binary(0);
else
while(num>0)
{
binary(num%10);
num=num/10;
}
puts(data);
getch();
}
我检查了我的编码,它工作正常。它将任何给定的整数转换为ASCII码。必须尝试让我知道这是否是您正在寻找的谢谢。