关于MikroC的错误

关于MikroC的错误,c,debugging,compiler-errors,pic,mikroc,C,Debugging,Compiler Errors,Pic,Mikroc,我正在用mikroC编程pic16f1823,我遇到了一些非常奇怪的错误 当我声明一个整数时,会出现一个错误,当我试图声明一个char*数组时,会出现一个错误,该错误表示字符太多。最奇怪的错误之一是“}”预期“}” 我的代码如下,如果您发现任何可能导致此类错误的错误,请通知我 #include <stdio.h> char *filter; char *filters[25] = {'1','6','11','2','7','12','3','8','13','4','9','14

我正在用mikroC编程pic16f1823,我遇到了一些非常奇怪的错误

当我声明一个整数时,会出现一个错误,当我试图声明一个char*数组时,会出现一个错误,该错误表示
字符太多
。最奇怪的错误之一是“}”预期“}”

我的代码如下,如果您发现任何可能导致此类错误的错误,请通知我

#include <stdio.h>

char *filter;
char *filters[25] = {'1','6','11','2','7','12','3','8','13','4','9','14','5','10','15'};//error: TOO many chars
int PositionOfFilters[] = {1,6,11,2,7,12,3,8,13,4,9,14,5,10,15};
int EEPROM_READ(void);
void main() {
     TRISA = 0;//all port A are set as outputs
     TRISC = 0;//all port C are set as outputs
     while(1){
              int prevState = RA2;//store the previous state of RA2 to see if the button was every pressed or not
              int i;
              unsigned int *address[15];
              i2c_Start();
              for(i = 0; i < 16; i++){
                    address[i] = i2c_read(0);//should return what pin is set high;
              }
              i2c_Stop();
           if(RA2 != prevState){ //if the state of RA2 is different than the previous state that means the button was pressed
                  LCD_Cmd(_LCD_CLEAR);
                  int position;//error invalid experison
                  int on;
                  Lcd_Out(2,14,'LOC'); //prints out the we are on local mode
                  for(i = 0; i<16;i++){
                        if(address[i]!=0x00){ //checking to see which pin is high as well as where it's corresponding position is
                            on = address[i]; //should work because only one number shouldn't be 0x00
                            position = i; //gets the corresponding position
                            break;
                        }
                  }
                  if(on == 0x06){
                        Lcd_Out(1,3,'filter 15');//must be filter 15 because there is no other filter that has 0x06;
                  }
                  else{
                       int j;
                       for(j = 0; j < 15; j++){
                             if(PositionOfFilters[j] == position){
                                   //we know what filter we are at
                                   filter = filters[j];
                                   break;
                             }
                     } '}' expected '}' found MyProject.c
                       char *finalFilter = 'filter ' + filter;
                       Lcd_Out(1,3,finalFilter);//Prints out which filter is on
                  }
                  //for the eeprom
                  EEPROM_READ();

           }
           else{
                Lcd_Out(2,14,'REM'); //will print out REM for remote mode
           }
     }
}

int EEPROM_READ(void){
      //figure out how long the eeprom data is
      //start storing the data in a array and then return that array
      //do this by using i2c_start() then eeprom_read(address) then i2c_restart
}
#包括
字符*过滤器;
字符*过滤器[25]={'1','6','11','2','7','12','3','8','13','4','9','14','5','10','15'}//错误:字符太多
int-PositionOfFilters[]={1,6,11,2,7,12,3,8,13,4,9,14,5,10,15};
int EEPROM_读取(无效);
void main(){
TRISA=0;//所有端口A都设置为输出
TRISC=0;//所有端口C都设置为输出
而(1){
int prevState=RA2;//存储RA2的前一个状态,以查看按钮是否每次按下
int i;
无符号整数*地址[15];
i2c_Start();
对于(i=0;i<16;i++){
地址[i]=i2c_read(0);//应返回设置为高的引脚;
}
i2c_停止();
if(RA2!=prevState){//如果RA2的状态与之前的状态不同,则表示按钮被按下
LCD_Cmd(_LCD_CLEAR);
int位置;//错误无效经验
int-on;
Lcd_Out(2,14,'LOC');//打印出我们处于本地模式

for(i=0;i过滤器声明错误。您声明了一个字符指针数组,并用字符文本初始化它

您需要指向一个字符的字符串的指针

char *filters[25] = { "1", "6", "11", "2", "7", "12", "3", "8", "13", "4", "9", "14", "5", "10", "15" }; 
这取决于过滤器的用途


第二个问题是

Lcd_Out(1, 3, 'filter 15');
当然,这一准则必须得到遵守

Lcd_Out(1, 3, "filter 15");
C字符串文本必须按
而不是


第三个问题

char *finalFilter = 'filter ' + filter;
这是错误的。如前所述,字符串必须是
“filter”
,并且不能用这种方式连接字符串。 例如,你可以这样做

char finalFilter[32];
sprintf(finalFilter, "%s%s", "filter", filter);

你确定
{
}
的总数相等吗?我更喜欢在
下面的新行
{
中为
设置格式,如果
-在相同的列位置,如
}
。这样可以提高这种情况下的可读性。只需检查它和所有的{and}您发送的第一次编辑将char*更改为仍然提供error@MOHAMMEDSALEH不。答案的第一个版本我给了你2个选择。为了更好地查看你的代码,你需要我现在在答案中留下的选项:char*with strings作为初始化器…谢谢你,我找到了答案,谢谢你的其他错误看着你指的out@MOHAMMEDSALEH不客气。如果足够,请按回答结束问题,并标记正确答案。