Self Creating Integers

Hello. I know it would be easier to create an int array, but I want the program to create integers as the user requests. For example, if the user enters 4, the program creates 4 integers with the names input. Each integer is better as an individual integer, not an element in an array.I'm not sure if this is a possibility with C++. Any responses would be greatly appreciated. Thank you.
How do you plan to reference (i.e. use) said integers if they have no name?

The whole point of an array (or better yet, a vector or deque) is to manage an unknown number of things.

Hope this helps.
This is possible...

-Have your program prompt the user for the variable names and values and store them someplace (maybe an array? lol)
-Open up the source code of your file (you want this to be a separate copy of the same source code), add in the newly named integers into it, save the file.
-Call up the compiler to compile that new source file.
-Exit current program and run new program with their new integers in .

...But not recommended.
You could probably fake it using a std::map or std::unordered_map (C++11) where the keys are the variable names and the values are, well, the values of the variables.
Kinda like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Use a C++11 compiler, please!
#include <iostream>
#include <string>
#include <unordered_map>

int main()
{
    std::cout << "Enter some variable names and values:\n";
    std::unordered_map<std::string, int> vars;
    while (true)
    {
        std::string name;
        int value;
        std::cout << ">> ";
        if (!(std::cin >> name >> value))
            break;
        vars[name] = value;
    }
    std::cout << "\nHere are your variables (sorry, they might be in a different order):\n";
    for (const auto& p : vars)
        std::cout << p.first << " = " << p.second << '\n';
}

Possible output:
Enter some variable names and values:
>> myInt 14
>> blah -3
>> yoloSwag 69
>> mostDescriptiveIntegerNameInTheHistoryOfEver -101
>> somethingBlahBlah 5
>> ^Z

Here are your variables (sorry, they might be in a different order):
somethingBlahBlah = 5
mostDescriptiveIntegerNameInTheHistoryOfEver = -101
yoloSwag = 69
blah = -3
myInt = 14
Topic archived. No new replies allowed.