http://www.perlmonks.org?node_id=496456


in reply to Re: If I was forced to use only one kind of loop for the rest of my days it would be a
in thread If I was forced to use only one kind of loop for the rest of my days it would be a

If I program C, I'd definitely go with for. (That's what I've voted for.) It's just much more general than while. To tell the truth, just about any looping construct is more general than while.
Now I'm curious. Could you give an example of a loop you could write with "for" that you couldn't write with "while"?
#include<stdio.h> int main(int argc, char** argv) { int a = 0; while(a++,a<10) { printf("%d\n",a); } }