Member Avatar for astockton

I am trying to use a for loop to print the contents of a single dimensional array. I am trying to use the loop counter in the 'cout' statement to provide a heading for the contents of each array element. code is below. I am using MS Visual Studio to write and compile the code and I receive the following error when I compile:

"error C2065: 'forCounter' : undeclared identifier"

I am not sure what I am doing wrong. Please help.

for (int forCounter = 0; forCounter < wageArraySize; forCounter++ );
		cout << "Salary between $" << wageArray[ forCounter ] << "00 and $" << wageArray[ forCounter ] << "99: " << wageArray[ forCounter ] << endl;

Recommended Answers

All 2 Replies

remove the semicolon at the end of the for loop statement!

Member Avatar for astockton

That fixed it, thank you for the help.

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.