-
help with chars...
hi all,
i was just wondering if it was posible to create a char with a name enter by the user e.g.
if the user enters 'welcome' it will create a char called 'welcome' for example
Code:
char name_entered_by_user[255]
thx for any help just ask if ur not clear on what i mean :)
-
Nope, not possible with C++ as you want it. However, you can kind of fake it with a map
Code:
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main()
{
map<string, string> strings;
// Assume the names are entered interactively ;)
strings["beep"] = "Beep!";
strings["boop"] = "Boop!";
strings["snic"] = "Snickerdoodle!";
map<string, string>::iterator i;
for (i = strings.begin(); i != strings.end(); ++i)
cout<< i->second <<endl;
}