std::string function(std::string buffer)
{
int Variable1 = 23;
if( !buffer.compare("Variable1")) <--- i want the user to input the variable name..and have my program match the input with the variable name of the program and return the value it contains
return Variable1; [U]<--- How do i convert this number into a c++ std::string?[/U]
}
return "turd"
lochnessmonster
0
Junior Poster
Recommended Answers
Jump to PostHow about a map?
std::map<std::string, int*>
Like
int func() { int var1 = 2, var2 = 11, var3 = 5, var4 = 13; std::map<std::string, int*> dict; dict["var1"] = &var1; dict["var2"] = &var2; dict["var3"] = &var3; dict["var4"] = &var4; std::string s = "var3"; return *dict[s]; …
All 3 Replies
gerard4143
371
Nearly a Posting Maven
pseudorandom21
166
Practically a Posting Shark
Caligulaminus
35
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.