i always wanted to know - does
does the same as:Code:for(int i = 0;i < 3;i++){ //code }
thanks for the replys.Code:while(i<3){ static int i = 0; //code i++; }
i always wanted to know - does
does the same as:Code:for(int i = 0;i < 3;i++){ //code }
thanks for the replys.Code:while(i<3){ static int i = 0; //code i++; }
no it does not - you check the condition i<3 outside the skope where i is defined
the right version will be
Code:{ int i=0; while(i<3) { //code i++; } }
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
... not to mention a for statement doesn't leave a static hanging around.
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
Unless you're using MSVC 6.0 . . . This doesn' t either.... not to mention a for statement doesn't leave a static hanging around.
But there's no reason you shouldn't use a for loop.Code:{ int i = 0; while(i < 3) { // code i ++; } }
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
> Unless you're using MSVC 6.0 . . . This doesn' t either.
Hmm... now you lost me. Don't static variables only get destroyed after main()?
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.