About 594,000 results
Open links in new tab
  1. Does C have a "foreach" loop construct? - Stack Overflow

    Almost all languages have a foreach loop or something similar. Does C have one? Can you post some example code?

  2. How do you get the index of the current iteration of a foreach loop?

    Sep 4, 2008 · However, the trick is to make the loop's condition listEnumerator.MoveNext() == true. Since the MoveNext method of an enumerator returns true if there is a next element and …

  3. c++ - For every character in string - Stack Overflow

    Feb 24, 2012 · (Outdated comment, that is still probably relevant for the OP:) It is not considered good form to use strlen in the loop condition, as it requires an O (n) operation on the string for …

  4. c# - How to iterate over a dictionary? - Stack Overflow

    What is the benefit of this, though? It's longer code than a foreach loop and worse performance because new List<string>(dictionary.Keys) will iterate dictionary.Count times before you even …

  5. How to make the for each loop function in C++ work with a …

    May 12, 2013 · 0 As @yngum suggests, you can get the VC++ for each extension to work with any arbitrary collection type by defining begin() and end() methods on the collection to return a …

  6. How do I skip an iteration of a `foreach` loop? - Stack Overflow

    Mar 17, 2009 · In Perl I can skip a foreach (or any loop) iteration with a next; command. Is there a way to skip over an iteration and jump to the next loop in C#? foreach (int number in numbers) …

  7. c++ - Use of for_each on map elements - Stack Overflow

    May 17, 2010 · From what I remembered, C++ map can return you an iterator of keys using map.begin (), you can use that iterator to loop over all the keys until it reach map.end (), and …

  8. How to loop through all enum values in C#? [duplicate]

    Unfortunately, this does not answer the question posed. The question was how to loop through the values of an enum. SLaks answered the question.

  9. How do I exit a foreach loop in C#? - Stack Overflow

    During testing I found that foreach loop after break go to the loop beging and not out of the loop. So I changed foreach into for and break in this case work correctly- after break program flow …

  10. for loop - C++ for each, pulling from vector elements - Stack …

    I am trying to do a foreach on a vector of attacks, each attack has a unique ID say, 1-3. The class method takes the keyboard input of 1-3. I am trying to use a foreach to run through my …