Need help with ARRAYS please!!!

I am trying to write a program that uses arrays and this is my first time. You have an index of 100 and then as long as you dont enter -1 the program will continue to ask you for a positive integer then once you enter -1 it asks you for a string of text to equal the amount of times you entered an integer. then it should display the answers as such:
example:

 
        Enter a positive integer (-1 to exit): 1
        Enter a positive integer (-1 to exit): 2
        Enter a positive integer (-1 to exit): 3
        Enter a positive integer (-1 to exit): 4
        Enter a positive integer (-1 to exit): -1
        Enter a string: a
        Enter a string: b  
        Enter a string: c
        Enter a string: d //enter a string shows only as much as positive integer

        1 : : a
        2 : : b
        3 : : c
        4 : : d



I don't know how to get it show up the way the example does, all I get is this:


        Enter a positive integer (-1 to exit): 1
        Enter a positive integer (-1 to exit): 2
        Enter a positive integer (-1 to exit): 3
        Enter a positive integer (-1 to exit): 4
        Enter a positive integer (-1 to exit): -1
        Enter a string: Enter a string: a
        Enter a string: b
        Enter a string: c  // just keeps repeating this 
         
        Press any key to continue...



Here is my code


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
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string string;
	int integer[100];
	int integerVar = -1; //integerVar is array index "I think". Stands for integer variable

	do
	{
		integerVar = integerVar + 1;
		if (integerVar > 100)
		{
			cout << "Highest possible amount is 100";
			break;
		}
		cout << "Enter a positive integer (-1 to exit): ";
		cin >> integer[integerVar];
		
	}
		while (integer[integerVar] != -1);
	
	for (int counter=0; counter<integer[integerVar]; counter=counter=1)
	{
		cout << "Enter a string: ";
		getline(cin, string);
	}    // I though this for statement would make string show up only as much as the integer question
	cout << integerVar << " : : " << string << endl;
}

What's wrong with the answer you got in your other thread?
Topic archived. No new replies allowed.