I have been working on a small console game using c++, i have done a lot to the game and now i have started making it so all the variables are been sourced from a text file which can be edited using notepad outside of the actual game.
I have looked a lots of tutorials and even the book "Visual c++ 6 for DUMMIES", i tested my code on a different application that was more simple before i tried this; but since then i have added a tonne of code and i will actually be using the variables for other things than displaying it on the screen.
i got it all going but i am having problems dealing with getting the right format and so on; I have about 20 errors so it's not looking good at the moment.
Heres the code including the variables being set.
1 2 3 4 5 6
|
char chaXPinc[50];
char savevalue[50];
char chahpinc[50];
char champinc[50];
char chaDamMinInc[50];
char chaDamMaxInc[50];
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
ifstream inputFile; //tells the computer you are going to input files
ofstream outputFile; //tells the computer you are going to output files
//Health Increasement Value
inputFile >> savevalue ; inputFile >> savevalue; inputFile >> savevalue; inputFile >> savevalue;
chahpinc = savevalue;
//Mana Increasement Value
inputFile >> savevalue ; inputFile >> savevalue; inputFile >> savevalue; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue;
champinc = savevalue;
//Damage Minimum Increasement Value
inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ;
chaDamMinInc = savevalue;
//Damage Maximum Increasement Value
inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ;
chaDamMaxInc = savevalue;
//Experience Increasement Value
inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ; inputFile >> savevalue ;
chaXPinc = savevalue;
inputFile.close()
|
Heres whats in the .TMS file.
1 2 3 4 5
|
Health.Increasement: 7
Mana.Increasement: 6
Damage.Minimum.Increasement: 3
Damage.Maximum.Increasement: 8
Experience.Increasement: 5
|
The errors they are giving are mostly
"
ISO C++ forbids assignment of arrays"
Cheers,
Mapster
EDIT:
I changed the variable types to string which stopped this error, now i get an error saying:
no match for 'operator*' in 'chalvl * chahpinc'
Now i realize this means i can't do anything with a string except display it, so what should i use instead of string so i can use these variables to multiply/subtract/add/divide and save them onto a file?
Thanks again,
Mapster