I need help assigning input to each cout

I'm using the count to produce multiple messages "Integer #" depending what number the user inputs for the first cin. If the user inputs the number 4 it should display:
Integer # 1:
Integer # 2:
Integer # 3:
Integer # 4:

My biggest problem is allowing the user to make input to each of those "Integer # N:". I want to allow the user to input an integer after each one, but I have no idea how to do it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  using namespace std;

int main()
{

int N=10; 
std::cout << "Please enter N: ";
std::cin >> N; 
std::string phrase = "Integer # "; 
for (int count=1; count<N; ++count) std::cout << phrase 
  << count << ":" << endl;
 
   
   return 0;
}

This code only outputs the integers in order, but I need to know how to assign input to each of the outputs. 
Its fairly simple. You can use an array but the array must have a constant size when it is declared. The other method is to use and STL containers like std::vector. I will show you how to use both.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
int main()
{
   int array[100];
   int N=10; 
   std::cout << "Please enter N: ";
   std::cin >> N;
   for (int count=0; count < N; ++count)
   {    
        std::cout << "Integer # " << count + 1 << ": ";
        std::cin >> array[i];
        std::cout << std::endl;
   }   
   return 0;
}


But remember N in this code must not be greater than 100. Now I'll show you the second option.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <vector>

int main()
{
   std::vector <int> Array;
   int temp;
   int N=10; 
   std::cout << "Please enter N: ";
   std::cin >> N;
   for (int count=0; count < N; ++count)
   {    
        std::cout << "Integer # " << count + 1 << ": ";
        std::cin >> temp;
        Array.push_back(temp);
        std::cout << std::endl;
   }   
   return 0;
}


Now in this code N can even be longer than 1000. You can learn more about vectors and their uses here:

http://www.cplusplus.com/reference/vector/vector/

I just want to discuss your error in the code. Its that when you write 'using namespace std;' then you don't need to put std:: in front of anything that is defined in the namespace std.
Topic archived. No new replies allowed.