Question about storing?

Write your question here.
For anyone who has a graphing calculator, there is a store function on the sto key. What it does is store a number as a letter. I was wondering if there is a similar function in C++, where I can run a random response generator and then store the output to that generator to a string, that I can then recall later. Thank you!
Look up std::map - in particular, you want to map strings (names) to values.

http://www.cplusplus.com/reference/map/
http://en.cppreference.com/w/cpp/container/map
Define "later", do you mean after your program has closed? Because then you would have to store the string to disk. Otherwise you seem to be asking if std::string variables exist...
No, I mean later in the program. Sorry.
Did the links help you? It's unclear because you only responded to Computergeek's post.
Well, not particularly. I'm a beginner, I don't really understand. I'm trying to read it and comprehend it. But lets say for example I want this:
1
2
3
4
int main ()
{
cout <<"His name is " <<randomname1[rand() %2]<<" .";
}


I want to know how can I "record" what the product of the random name is, and then have the program display it later in the program, if that makes sense.
Here is a demo of what you want:
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
#include <iostream>
#include <string>
#include <map>

int main()
{
    std::map<std::string /*name*/, double /*value*/> vals;
    std::string cmd;
    while(std::cin >> cmd && cmd != "exit")
    {
        if(cmd == "store")
        {
            double v;
            std::string name;
            if(std::cin >> v >> name)
            {
                vals[name] = v;
            }
        }
        else if(cmd == "recall")
        {
            std::string name;
            if(std::cin >> name)
            {
                std::cout << vals[name] << std::endl;
            }
        }
    }
}
Try using 'store 7 x' 'store 3 y' 'recall z' 'recall x'
http://ideone.com/Y3mOGn
Thank you, and sorry to ask again, but that program requires you inputting the information correct? Like, the user has to type in store (number) as x. Then recall x. Is it possible to, while in the program, it runs a random variable generator. And it develops an output. Then you can have it later display the output that it originally came up with?
It is perfectly possible, the I/O was just for demonstration purposes since you mentioned the TI calculators store and recall functionality. What is confusing about doing it randomly?
So, I tried to make an array, with a line like this:

 
int femalename[1] = {femalenames[rand() %2]};


However, an error came up saying this:
error: cannot convert 'std::string {aka std::basic_string<char>}' to 'int' in initialization|

What does that error mean and how do I fix it?
Why are you trying to make an array? Why is it only one element?

I think you have a fundamental misconception somewhere.
Topic archived. No new replies allowed.