c - What is a neat way of breaking out of many for loops at once? -


Suppose that in an in-loop, on the event of an incident I would have to break out of three or four nested for loop at one go . What is a clean way to do this?

What do I do flags like this:

  int i, j, k; Int flag1 = 0; Int flag2 = 0; For (i = 0; i & lt; 100; i ++) {for (j = 0; j & lt; 100; j ++) {for (k = 0; k & lt; 100; k + +) {If (k == 50) {Flag1 = 1; Flag2 = 1; break; }} If (flag 1 == 1) break; } If (flag2 == 1) break; }  

I do not think this is particularly clean.

How do you accomplish the same thing? (w / o jumps)

Use goto It is clear and simple.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -