c - Two semicolons inside a for-loop parentheses -
im customising code found on internet (it's adafruit tweet receipt). cannot understand many parts of code perplexing me for-loop 2 semicolons inside parentheses
boolean jsonparse(int depth, byte endchar) { int c, i; boolean readname = true; for(;;) { //<--------- while(isspace(c = timedread())); // scan past whitespace if(c < 0) return false; // timeout if(c == endchar) return true; // eod if(c == '{') { // object follows if(!jsonparse(depth + 1, '}')) return false; if(!depth) return true; // end of file if(depth == resultsdepth) { // end of object in results list
what for(;;) mean? (it's arduino program guess it's in c)
for(;;) { }
functionally means
while (true) { }
it break loop/ return loop based on condition inside loop body.
the reason for(;;)
loops forever because for
has 3 parts, each of optional. first part initializes loop; second decides whether or not continue loop, , third @ end of each iteration. full form, typically see this:
for(i = 0; < 10; i++)
if first (initialization) or last (end-of-iteration) parts missing, nothing done in place. if middle (test) part missing, acts though true
there in place. for(;;)
same for(;true;)
', (as shown above) same while (true)
.
Comments
Post a Comment