It doesn't compile, why?

#include <iostream>
#include <string>

using namespace std;

int main()
{
	
	for(int cnt1 = 0, int cnt2 = 10;  cnt1<10; ++cnt1, --cnt2)
	{
		cout << cnt1 << "--------Hello!---------" << cnt2 << endl;
	}
	
	system("PAUSE");
}

Sorry solved the problem myself

Good. Cuz the answer would've been "Because you wrote it wrong"

Without details, and our lack of psychic ability, what else could we say?

Without details, and our lack of psychic ability, what else could we say?

I could say:
1. the declaration of the variables in the loop is wrong, there's an int to many.

2. <cstdlib> has to be included for system() ;)

wrong usage of for loop

:icon_razz: back....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.