TOC | Prev | Next

Assignment and equality

=   assignment
==  equality comparison

Assignment still gives a result to the expression.

int n = 5;
if ( n = 0 ) { /* WRONG */
    printf( "I will never succeed\n" );
}
if ( n == 0 ) {
    printf( "Just as predicted\n" );
}
TOC | Prev | Next