Single-line if statements in C - which statements are affected? -
i'm trying translate code c language. don't have quick access c compiler , found myself confused single-line if statements. know statements like:
if (condition) [statement] and
if (condition) [statement] can evaluated without brackets, i.e. equivalent to:
if (condition) {[statement]} and
if (condition) {[statement]} respectively, i'm not sure sample code i'm dealing with. goes:
if (ge.g[*l][*k].s==1) *i=1; else *i=ne; *j=*l; i feel second line not affected if statement, it's not obvious context of code. long story short: above equivalent to:
if (ge.g[*l][*k].s==1) {*i=1;} else {*i=ne;} *j=*l; or
if (ge.g[*l][*k].s==1) {*i=1;} else {*i=ne; *j=*l;} ?
following code
if (ge.g[*l][*k].s==1) *i=1; else *i=ne; *j=*l; when formatted correctly written this:
if (ge.g[*l][*k].s==1) *i=1; else *i=ne; *j=*l; and equivalent code with braces:
if (ge.g[*l][*k].s==1) { *i=1; } else { *i=ne; } *j=*l; this shows importance of code being formatted correctly readable , understandable humans , not comilers.
Comments
Post a Comment