Possible Duplicate:
The ternary (conditional) operator in C
This is a code example from my teacher assistance. I don't have a clue what total = total*2+ (n=='1'? 1:0);
does. I think it multiply the total with by 2, but what is with the question mark and the 1:0
ratio ?
int bcvt(FILE *infile){
char n;
int i, total=0;
for(i=0; i<32; i++){
fscanf(infile, "%c", &n);
total = total*2+ (n=='1'? 1:0);
}
char dummy;
fscanf(infile, "%c", &dummy);
return total;
}