Creating and saving config files
Ive managed to create and save a config file, worked fine except at first the very first value saved was all messed up. it was some weird symbols I've never seen before (along with a very tiny "L"). Now the first and second ones are messed up, here are some values (taken from the saved config file), they are different each time i run the program. (they are supposed to be numbers)
Ok apparently i cant even post the messed up values cause it causes an xml parsing error when i hit the post new thread button. But trust me they are messed up.
Ok the last one the second value came out ok. What i cant figure out is why this is happening... any ideas?
Here is my function for converting numbers to strings:
1const char * IntToString(int T)
3 const char * Value;
4 std::string Temp;
5 std::stringstream ss;
6 ss << T;
7 Temp = ss.str();
8 Value = Temp.c_str();
9 return Value;
and here is my call to al_set_config_value
this function is part of a class(obviously) i made just to test the functionality of the ini files as im new to it.
You're returning the stored const char* .c_str() from a temporary object, namely Temp, your string. When the function exits Temp goes out of scope, just like its name says it does and then the reference you are holding is no longer valid. Return a copy of a std::string instead and then .c_str() it later when you need to.
Thread #615130. Printed from Allegro.cc
That did it! Thank you both for your help! I really appreciate it.