Codevision AVR 中的一个错误

An Err in Codevision AVR

我在 codevision 中编写计算器,我得到这个错误:

Error: C:\cvavr\BIN\Thrust Calculator\TC.c(112): ')' expected

这个错误与我的这部分代码有关(机器人的第 4 行):

intnum1 = (int atoi(num1[q])) * 10^(i-q-1) + intnum1; 

有什么问题吗?

这是我的代码:

#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;       

}

如果sm能回答我,我将不胜感激:)

intnum1 = (int atoi(num1[q])) * 10^(i-q-1) + intnum1;确实是问题

你到底想在这里做什么?如果您想将整个结果转换为 int,那么您想要的是:

intnum1 = (int) (atoi(num1[q])) * (10^(i-q-1))) + intnum1; 

我不确定这里需要什么操作顺序,但您想将整个结果转换为 int 以将其存储在 intnum1