for loop

Hi, I am going through a c++ book and came across a new way to write a for loop, it was taught using a vector but I wanted to see if i could use it for other things. It works until i want to put a new line in, with the new line being in it, it causes weird information to be printed out on the console.

The code I am using is below. When i type numbers such as 80, it prints that something is corrupted, other numbers print something about a stack, and other numbers just print weird shapes. So obviously I know this code is wrong since it is printing like this, but I am wondering why the newline causes this to occur. And is this way of doing a for loop good for this such thing or is it better just to be used to push information to a vector, like the example from the book?

1
2
3
 	for (int num; cin >> num;)
		cout << "\n" + num ;
	
You mean <<, not +.
....... of course lol. Such a stupid mistake. Thanks for answering :)
Topic archived. No new replies allowed.