offset values and operators to increment pointers

line 17
"Counter" is undefined. how do I fix this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Listing8.9.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;

int main()
{
	cout << "How many integers you wish to enter? ";
	int numEntries = 0;
	cin >> numEntries;

	int* pointsToInts = new int[numEntries];
	cout << "Allocated for " << numEntries << " integers" << endl;
	for (int counter = 0; counter < numEntries; ++counter);
	{
		cout << "Enter number " << counter << ": ";
		cin >> *(pointsToInts + counter);
	}

	cout << "Displaying all numbers entered: " << endl;
	for (int counter = 0; counter < numEntries; ++counter)
		cout << *(pointsToInts++) << " ";

	cout << endl;

	// return pointer to initial position
	pointsToInts -= numEntries;

	// done with using memory? release
	delete[]pointsToInts;

	return 0;

}
for (int counter = 0; counter < numEntries; ++counter);

What's the last character in that line ... ?

Where does the for loop (and hence the scope of counter) end?
Last edited on
oh ok. thank you!!
i was sitting there for 30 mins. couldnt figured it out.
thank you
Topic archived. No new replies allowed.