-2

我在 codevision 中对计算器进行编码,我得到了这个错误:

错误:C:\cvavr\BIN\推力计算器\TC.c(112): ')' 预期

这个错误与我的这部分代码(机器人的第 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 能回答我,我将不胜感激:)

4

1 回答 1

0

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

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

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

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

于 2017-04-12T21:39:42.103 回答