LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   E1_8.c:16:4: error: expression is not assignable (https://www.linuxquestions.org/questions/programming-9/e1_8-c-16-4-error-expression-is-not-assignable-4175654349/)

anon033 05-21-2019 07:01 PM

E1_8.c:16:4: error: expression is not assignable
 
I am doing an assignment where I need to count tabs, newlines and spaces. I have this code

Code:


#include <stdio.h>

int main() {

        int c, nl, bl, tb;

        nl = 0;
        bl = 0;

        tb = 0;

        while ((c = getchar()) != EOF)
                if (c == '\n')
                        ++nl;
                else (c == '\t')
                        ++bl;
        printf("%d\n", bl);
        printf("%d\n", nl);

}

This returns this error:

Code:

E1_8.c:16:4: error: expression is not assignable
                        ++bl;
                        ^
1 error generated.

I am confused...

hydrurga 05-21-2019 07:05 PM

else if


All times are GMT -5. The time now is 12:23 PM.