This is how you code your requirement
#include <iostream>
int *ptr_to_no_of_enemies = 0;
int main()
{
int no_of_enemies = 0;
std::cout << "Enter the number of enemies : ";
std::cin >> no_of_enemies;
ptr_to_no_of_enemies = new int[no_of_enemies];
/* you are dynamically creating an array and passing the starting
address to a pointer which is global. Using this pointer, you
can work with the contents of the array
*/
// call all your functions out here.. and get your job done :)
/*
please ensure that you free the memory allocated to create the
array dymanically
*/
delete [] ptr_to_no_of_enemies;
return 0;
}
PS: As mentioned by others, its preferable you don't create a global variable and allow that variable to point to a dynamically allocated array