C++ “list iterator error”-Collection of common programming errors

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 run your code and enter 0 immediately before adding any numbers, you’ll get the error you’re seeing.