In this code I am just printing an integer array to check if it contains the value it should contain..(array should not contain any negative value at this point)
Code: Select all
int test=0;char val[5]={};
int l=0;
for(int k=0;exp[k]!=0;k++)
{
test=exp[k]; //taking in value
int_to_ascii(test, val); //converting to ASCII
print(val,2*l,0xd); //my print function-takes a pointer, an offset, and a color value
for(int m=0;val[m]!='\0';m++) //clearing out val for next iteration
val[m]='\0';
l=k*0xA0; //next line
}
but it always do
- 20480
20530
5
If I try to force some other value into exp[0], then20530 ;omits the first value
5
20530P\. ;invalid values, there is no way this can happen
5
This is my int_to_ascii code:
Code: Select all
if(src==0)
{
stack[i++]='\0'; //pushing NULL and 0 to stack
stack[i++]='0';
}
else
{
while(src!=0) //converting last digit and pushing to stack
{
stack[i]=(0x30+src%10);
src/=10;
i++;
}
}
i--;
len=i;
while(i>=0)
{
dest[len-i]=stack[i]; //popping and placing from left to right
i--; //inorder not to get reversed.
}