Read and write from standard I\O streams causes error

0

Why this cause my program to finish with following exit code

deque<int> di((istream_iterator<int>(cin)), (istream_iterator<int>()));
copy(di.begin(), di.end(), ostream_iterator<int>(cout, " "));

The thread 0x5d4 has exited with code -1073741749 (0xc000004b).

The program '[3776] Josuttis.exe' has exited with code -1073741510 (0xc000013a).

EDIT:

This error i have during program execution:

Error i got

Actually, enter "1 1 1 1 9 Ctrl+C". May be Ctrl+C is wrong here?

EDIT2: Ouch, i think it is because of Ctrl+C - CTRL+C (Break), Sorry for bothering you!

c++
io
stl
stream
iterator
asked on Stack Overflow Jun 30, 2015 by Yola • edited Jun 30, 2015 by Yola

1 Answer

3

Just because your program crashed on a particular line doesn't mean that's where the bug is. Although the cited code fragment is slightly ...odd, technically I see nothing wrong with it.

The bug could've occured anywhere else, previously, where memory got corrupted, which eventually results in a crash at this particular point.

See https://stackoverflow.com/help/mcve for some helpful tips regarding how you can track down the real problem.

Welcome to C++.

answered on Stack Overflow Jun 30, 2015 by Sam Varshavchik • edited May 23, 2017 by Community

User contributions licensed under CC BY-SA 3.0