gpt4 book ai didi

c - Codevision AVR 中的错​​误

转载 作者:行者123 更新时间:2023-11-30 20:34:04 25 4
gpt4 key购买 nike

我在 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 中。

关于c - Codevision AVR 中的错​​误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43379858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com