im coding the calculator in codevision and i get this Err :
Error: C:\cvavr\BIN\Thrust Calculator\TC.c(112): ')' expected
this err related to this part of my code (4th line from bot):
intnum1 = (int atoi(num1[q])) * 10^(i-q-1) + intnum1;
What is the problem ?
this is my code :
#include <mega32.h>
#include <alcd.h>
#include <delay.h>
#include <string.h>
//defining PTND.i
#define C0 PIND.4
#define C1 PIND.5
#define C2 PIND.6
#define C3 PIND.7
flash char shift[4] = {0b11111110,0b11111101,0b11111011,0b11110111};
flash char layout[16] = {'7','8','9','/',
'4','5','6','*',
'1','2','3','-',
'C','0','=','+'};
char keypad(void);
int fnum1(void);
char num1[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
char num2[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int i,q, intnum1 = 0;
int t;
void main(void)
{
DDRD = 0X0F;
PORTD = 0XF0;
lcd_init(16);
keypad();
while (1)
{
}
}
/* keypad function */
char keypad(void)
{
int row = 0, position = 0;
while (1)
{
for(row=0; row<4; row++)
{
int COLUMN = -1;
PORTD = shift[row];
//finding column
if(C0 == 0) {COLUMN = 0;}
if(C1 == 0) {COLUMN = 1;}
if(C2 == 0) {COLUMN = 2;}
if(C3 == 0) {COLUMN = 3;}
//know if sm clik the btn
if(COLUMN != -1)
{
//calculating the position
position = row*4 + COLUMN;
//do nothing during the pushing
while(C0 == 0) {}
while(C1 == 0) {}
while(C2 == 0) {}
while(C3 == 0) {}
//C as lcd clear
if(layout[position] == 'C') lcd_clear();
else
//return the keypad value
return layout[position];
}
delay_ms(50);
}
}
}
int fnum1(void)
{
if( keypad() != '')
{
num1[i] = keypad();
i = i + 1;
}
if ( keypad() == '=')
{
for( t = 0 ; t <= i ; t++)
{
lcd_putchar(num1[t]);
}
}
for( q = 0 ; q <= i ; q++)
{
intnum1 = (int atoi(num1[q])) * 10^(i-q-1) + intnum1;
}
lcd_putchar(keypad());
return intnum1;
}
I'll appreciate if sm can answer me :)
intnum1 = (int atoi(num1[q])) * 10^(i-q-1) + intnum1;
is indeed the problem.
What exactly are you trying to do here? If you want to cast the entire result to an int
as it appears then what you want is this:
intnum1 = (int) (atoi(num1[q])) * (10^(i-q-1))) + intnum1;
I am not sure what order of operations are required here, but you want to cast the entire result to int to store it in intnum1
.