Lvalue Required As Left Operand Of Assignment Arduino

Bonjour,

Pour mon projet en SI cette année je dois faire un pilulier électronique, je me charge de la base de données (des tableaux) sous Arduino

Ainsi j'ai commencé la fonction dans laquelle on connait le stockage restant des magasins et où les plaquettes sont présentes (d'où le tableau) afin que l'autre programme (qui n'est pas à ma charge) sache où stocker les nouvelles plaquettes entrantes (il y a 5 magasins au total, on peut stocker 3 plaquettes de médicaments dans chacune d'entre-elle soit 15 plaq. au total)

J'ai alors écrit ce code :

void presenceplaq(){

      char i = 0;

  char j = 0;

  boolean contmag[i][j];                    

    for (i = 0; i < 3; i++){

        for(j = 0; j < 5; j++){

          contmag[i][j]=0;

                              }

                           }               

    boolean a = 0;                            //variable pour le programme externe (nouvelle plaquette entrante ?)

    char k = 15-k;                            //nombre total de places restantes

    if(a = 1){ contmag[i][j] = 1;                 //1ère ligne qui se remplie

                j++;              

                k++;

                Serial.print(k);               

              }

    else if(a=1 && j=5){ i++;                  //quand arrive à mag 5, passer à la 2eme ligne

                            j = 0;

                            contmag[i][j] = 1;

                            k++;

                            Serial.print(k);

                          }

                      }

  Et voici le message d'erreur :

lvalue required as left operand of assignment

à la ligne 22 (càd "else if(a=1 && j=5)")

Merci d'avance !

-
Edité par EnirisBa 4 janvier 2018 à 12:14:40

  1. Registered User
    Join Date
    Oct 2010
    Posts
    79

    Lvalue required as increment operand

    #include <stdio.h> int main(void) { int iVar; //line 1 iVar = 20; //line 2 ++iVar; //line 3 printf( "\niVar : %d\n", iVar ); // line 4 iVar--; // line 5 printf( "\niVar : %d\n", iVar ); // line 6 iVar + ++iVar--; //line 7 printf( "\niVar : %d\n", iVar ); // line 8 ++( iVar + iVar ); // line 9 printf( "\niVar : %d\n", iVar ); // line 10 return 0; // line 11 }
    What's the problem?

  2. C++ Witch
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    25,792
    Look up a C++ Reference and learn How To Ask Questions The Smart Way
    Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    What exactly are you trying to do with these two statements?
    The error message is basically saying that you are trying to increment something that cannot be assigned to, e.g., it is the temporary that resulted from another operation.

  3. Registered User
    Join Date
    Oct 2010
    Posts
    79
    This code is pretty much simple arithmetic since my teacher is trying to teach us how to use operators. I don't get why it doesn't add together... Do those statements not work at all?


  4. Registered User
    Join Date
    Oct 2010
    Posts
    79
    That really helps, thanks.


0 comments

Leave a Reply

Your email address will not be published. Required fields are marked *