Invalid digit 8 in octal constant arduino как исправить

  1. Скетч для робота с ик приемником, ide ругается:invalid digit «8» in octal constant
    Понять в чем проблема смог, а как решить ее не могу понять все еще.
    Скетч:

    const long IR_COMMAND_FORWARD_CODES[] = { 377281, 7503, 2 };
    const long IR_COMMAND_BACKWARD_CODES[] = { 377282, 1583, 8 };
    const long IR_COMMAND_TURN_LEFT_CODES[] = { 377278, 0783, 4 };
    const long IR_COMMAND_TURN_RIGHT_CODES[] = { 377279, 7103, 6 };
    const long IR_COMMAND_FORWARD_LEFT_CODES[] = { 377278, 4863, 1 };
    const long IR_COMMAND_FORWARD_RIGHT_CODES[] = { 377280, 1183, 3 };
    const long IR_COMMAND_BACKWARD_LEFT_CODES[] = { 377280, 5263, 9 };
    const long IR_COMMAND_BACKWARD_RIGHT_CODES[] = { 377278, 8943, 7 };
    const long IR_COMMAND_STOP_CODES[] = { 377281, 3423, 5 };
    const long IR_COMMAND_VERY_SLOW_CODES[] = { 377280, 3223, 40 };
    const long IR_COMMAND_SLOW_CODES[] = {377281, 9543, 43 };
    const long IR_COMMAND_FAST_CODES[] = { 377278, 6903, 26 };
    const long IR_COMMAND_VERY_FAST_CODES[] = { 377279, 0473, 27 };
     
  2. А что вам непонятно? 0 перед числом говорит, что это число — в восьмеричной системе счисления, а там, как известно, нет цифры 8.

    0x перед числом — говорит, что это число в шестнадцатеричной системе счисления.

    Короче — уберите 0 спереди у чисел 0783 и 0473 — они там не нужны.

@sjoch

Hi.

I came across a strange errormessage and it might be a bug in the 1.0.5 version of the arduino software.

The part of the code that gets the error looks like this:
» if (i == 01) catchd01 = t;
if (i == 02) catchd02 = t;
if (i == 03) catchd03 = t;
if (i == 04) catchd04 = t;
if (i == 05) catchd05 = t;
if (i == 06) catchd06 = t;
if (i == 07) catchd07 = t;
if (i == 08) catchd08 = t;
if (i == 09) catchd09 = t;
«

And the compiler only complains on the last 2 lines.

error: invalid digit «8» in octal constant
error: invalid digit «9» in octal constant

So, whats wrong? it compiles good if all zeros are removed from the i == part.
But shouldnt it complain on all 9 lines if its the zero that is the problem.. why just 8 and 9?

@lestofante

because the compiler thinks you are using OCTAL number, and octal number
goes from 0 to 7.
Also, if this was a bug, was a COMPILER fault, you should had ask to
avr-gcc’s folks.

2013/6/30 sjoch notifications@github.com

Hi.

I came across a strange errormessage and it might be a bug in the 1.0.5
version of the arduino software.

The part of the code that gets the error looks like this:
» if (i == 01) catchd01 = t;
if (i == 02) catchd02 = t;
if (i == 03) catchd03 = t;
if (i == 04) catchd04 = t;
if (i == 05) catchd05 = t;
if (i == 06) catchd06 = t;
if (i == 07) catchd07 = t;
if (i == 08) catchd08 = t;
if (i == 09) catchd09 = t;
«

And the compiler only complains on the last 2 lines.

error: invalid digit «8» in octal constant
error: invalid digit «9» in octal constant

So, whats wrong? it compiles good if all zeros are removed from the i ==
part.
But shouldnt it complain on all 9 lines if its the zero that is the
problem.. why just 8 and 9?


Reply to this email directly or view it on GitHubhttps://github.com//issues/1490
.

@cmaglie

A constant number starting with «0» is interpreted as octal by the compiler, you must write «8» instead of «08».
BTW programming questions should be addressed to the forum.

http://forum.arduino.cc

C

@srknthcse

Error solved but i need clear explanation can anybody explain .thank you

@shaishu03

Error resuelto, pero necesito una explicación clara, ¿alguien puede explicarme? Gracias.

como lo solucionaste?

@arduino
arduino

locked as resolved and limited conversation to collaborators

Oct 21, 2022

Arduino Forum

Loading

mat

mat аватар

Offline

Зарегистрирован: 05.07.2012

Не…

Вот, для других параметров, этот же фрагмент, вопросов нет
{                                                   
   { 19, 2857,   12, 8571,   «0.35mm», » 999rpm» },
   { 16, 8750,   11, 2500,   «0.40mm», » 999rpm» },
   { 13, 5000,    9,    0,   «0.50mm», » 999rpm» },
   { 11, 2500,    7, 5000,   «0.60mm», » 950rpm» },
   {  9, 6429,    6, 4286,   «0.70mm», » 810rpm» },
   {  9,    0,    6,    0,   «0.75mm», » 760rpm» },
   {  8, 4375,    5, 6250,   «0.80mm», » 710rpm» },
   {  6, 7500,    4, 5000,   «1.00mm», » 560rpm» },
   {  5, 4000,    3, 6000,   «1.25mm», » 460rpm» },
   {  4, 5000,    3,    0,   «1.50mm», » 380rpm» },
   {  3, 8571,    2, 5714,   «1.75mm», » 320rpm» },
   {  3, 3750,    2, 2500,   «2.00mm», » 280rpm» },
   {  2, 7000,    1, 8000,   «2.50mm», » 220rpm» },
   {  2, 2500,    1, 5000,   «3.00mm», » 190rpm» },
   {  1, 6875,    1, 1250,   «4.00mm», » 140rpm» },
};

i m learning c programming and i don’t knonw what is going wrong with this program

the error code in the build message is

error: invalid digit «8» in octal constant.

can any one help please , and thank you =)

#include <stdio.h>
#include <stdlib.h>

int ch ;
int codeS , codeH;
int ph = 1 , ad = 2 , lb = 3 , us = 4;

int main()

{

  //int ch ;

  printf("n Bienvenue à SHCPahrma n Veulleiz Choisir Votre Code Section n ph : 1t ad : 2t lb : 3t us : 4tn num secteur ");
  scanf("%d",&ch);
  printf("n Entrer votre code secteur t = ");
  scanf("%d",&codeS);
  printf("n Entrer Code Horaire t = ");
  scanf("%d",&codeH);




  // ch = 1223 ;
   //printf("%d",ch);
  if ((ch == 1) && (codeS == 1111) && (codeH == 0815))
    {
        printf("Bienvenue Mr le Pharmacienn");
    }
    else if ((ch == 2) && (codeS == 2222) && (codeH == 0815))
    {
        printf("Bienvenue Mr l'Administrativen");
    }
    else if ((ch == 3) && (codeS == 3333) && (codeH == 0717))
    {
        printf("Bienvenue Mr agent laboratoiren");
    }

    else if ((ch == 4) && (codeS == 3333) && (codeH == 0717))
    {
        printf("Bienvenue Mr agent Usine n");
    }

    else
    {
        printf("Accées Interdit veullier Contacter l'administrationn")
    }


    return 0;
}

Понравилась статья? Поделить с друзьями:
  • Как составить сказку про девочку
  • Как найти косинус угла имея стороны
  • Ошибки кеша торрент как исправить
  • Как вконтакте найти человека по вузу
  • Как найти вероятность в математике формула огэ