{"id":5355,"date":"2014-03-30T21:02:44","date_gmt":"2014-03-30T21:02:44","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/c-list-iterator-error-collection-of-common-programming-errors\/"},"modified":"2014-03-30T21:02:44","modified_gmt":"2014-03-30T21:02:44","slug":"c-list-iterator-error-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/c-list-iterator-error-collection-of-common-programming-errors\/","title":{"rendered":"C++ &ldquo;list iterator error&rdquo;-Collection of common programming errors"},"content":{"rendered":"<p>You have a semicolon at the end of your <code>for<\/code> statement<\/p>\n<pre><code>for (pos = numbers.begin(); pos != numbers.end(); pos++) ;\n                                                        ^^^\n<\/code><\/pre>\n<p>Remove that and your code should work.<\/p>\n<p><strong>EDIT:<\/strong><\/p>\n<p>Note that if your list is empty, the returned iterator value cannot be dereferenced, which could be the cause of your runtime error. So if you run your code and enter <code>0<\/code> immediately before adding any numbers, you&#8217;ll get the error you&#8217;re seeing.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You have a semicolon at the end of your for statement for (pos = numbers.begin(); pos != numbers.end(); pos++) ; ^^^ Remove that and your code should work. EDIT: Note that if your list is empty, the returned iterator value cannot be dereferenced, which could be the cause of your runtime error. So if you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5355","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5355"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5355\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}