I have managed to save files in c++, and they turn out as strings. is there any way to save a float, and then load the file as a float? heres what I need it for. I am making a video game, and I need to be able to save certain variables of the game, most of them being floats. whenever I try it, it translates the numbers into a character, and does not work properly. I probably made this very confusing, but, I will do my best to answer any questions about this and I will try all suggestions.
ifstream myinputfile("input.txt");
ofstream myoutputfile("output.txt");
float number;
myinputfile >> number; // get number from file
myoutputfile << number; // save number into file
Im going to test it now...I cant seem to get it to allow input, I get this for output "-1.99979". My guess is that it doesn't allow me to do input.. because number already receives a value from somewhere?
I think the problem I have with mine, is that everything revolves around a set formula, as the first part of my save and load have for strings. the float is the anomaly, so doesn't fit very well.
save:
Im going to just add too this later, this particular computer that I am on seems to be evil.