This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

error in IF

why i have error in istruction IF
this is the code

for (i=1; i<=50; i++)

                 if (ram1[i] = 0 && ram1[i+1] = 1)
                        {                lcd_write_long_number(80,75,i);

Parents
  • Many errors there - get a good C book.

    = is assign.
    == is equality.

    If you want to compare, you should use two (2) equal sign, i.e.:

    for (i=1; i<=50; i++) {
        if (ram1[i] == 0 && ram1[i+1] == 1) {
            lcd_write_long_number(80,75,i);
        }
    }
    

    Count your braces - or make sure that when you cut demo code, you always copy balanced blocks.

    It might be a good idea to switch from tab characters to spaces when you indent - a lot of tools works better with space-indented text, since different tools use different width for a tab character.

    By the way - why post a bit of code, but not post the error message that the compiler prints? Don't you think the actual error messages are importent? The compiler vendor spends quite a lot of time trying th create meaningful error messages, i.e. to tell you exactly what you do wrong. Read the error message, instead of just counting number of messages.

Reply
  • Many errors there - get a good C book.

    = is assign.
    == is equality.

    If you want to compare, you should use two (2) equal sign, i.e.:

    for (i=1; i<=50; i++) {
        if (ram1[i] == 0 && ram1[i+1] == 1) {
            lcd_write_long_number(80,75,i);
        }
    }
    

    Count your braces - or make sure that when you cut demo code, you always copy balanced blocks.

    It might be a good idea to switch from tab characters to spaces when you indent - a lot of tools works better with space-indented text, since different tools use different width for a tab character.

    By the way - why post a bit of code, but not post the error message that the compiler prints? Don't you think the actual error messages are importent? The compiler vendor spends quite a lot of time trying th create meaningful error messages, i.e. to tell you exactly what you do wrong. Read the error message, instead of just counting number of messages.

Children