I'm trying to perform simple addition after taking 2 number inputs from user. Everything is running fine and addition is happening properly. The issue i'm facing is that whenever i wish to check if a number that is to be displayed is greater than 10 or not, it doesn't happen. Like my If condition to check the value is incorrect. I haven't been able to figure out why its wrong or how to fix it. I would appreciate if someone could explain what exactly i'm doing wrong.
Sorry if the code seems a bit messed up, i'm still learning OS development :)
//First Number Input
terminal_writestring("First Number:");
unsigned char c = 0, ar[100]={0}, i = 0;
init_pics(0x20, 0x28);
while(c!=1)
{
if(inb(0x60)!=c)
{
c = inb(0x60);
if(c>0){
terminal_putchar(scancode[c]); //print on screen
if(scancode[c] == '\n'){
outb(0x60, scancode[c]);
break;
}
ar[i] = c;
i++;
}
}
}
//Second number input
terminal_writestring("Second Number:");
unsigned char mn[100]={0}, j = 0;
c = 0;
while(c!=1)
{
if(inb(0x60)!=c)
{
c = inb(0x60);
if(c>0){
terminal_putchar(scancode[c]); //print on screen
if(scancode[c] == '\n'){
outb(0x60, scancode[c]);
break;
}
mn[j] = c;
j++;
}
}
}
//add
terminal_writestring("Sum: ");
unsigned char temp[100]={0}, k = 0, count = j;
while(j > 0){
temp[j]=scancode[mn[j]+ar[i]];
j--;
i--;
}
//problem is here, if condition never gets checked
if(temp[j]>10){
terminal_writestring("yo");
}
for(k=0;k<count;k++){
if(temp[k]>0) //to remove white space
terminal_putchar(temp[k]-1);
}
Aucun commentaire:
Enregistrer un commentaire