Joe for (i=0; i < lim-1 && (c=getchar()) != '\n' && c != EOF; ++i) s[i] = c; easy: Rewrite the above without using '&&' or '||'. (less) easy: Avoid using the 'if' keyword.
Ra8 a false Boolean will get the value of zero so if one is false the whole product will be zero, ie: they must be all true to be != 0 for (i=0; (i < lim-1 ) * ((c=getchar()) != '\n' )*( c != EOF)!=0; ++i) s[i] = c;
Joe Very elegant Ra8, that's what I had in mind. A colleague of mine used the ternary operator: for(i=0; i<lim-1 ? (c=getchar()) != '\n' ? c != EOF : 0 : 0 ; ++i) s[i] = c;