windows - c++ how to read and write within a file -


I want to create a text based RPG game, but to run a problem, enough new "C" Know, some concepts, but still learning, I want to know; How do I open a file and edit values ​​in it? It is said that there is a file named after my health, for health and set to 100. I know that you can only reduce the charity from the loss you have done, but I do not know how I handle health and how I am doing it, while my program goes away.

Meaning This is the most I:

  ifstream objectFile ("health.txt"); String health; Double no. Cout & lt; & Lt; "Welcome" & lt; & Lt; Endl; Objectfile & gt; & Gt; Health & gt; & Gt; Noah; Cout & lt; & Lt; Health & lt; & Lt; '' & Lt; & Lt; Noah-15;  

no = health number so far does all my programs, reads the file, and reduces 15 to 100, because damages the monster but how do I "accept it "And want to subtract it from 15? Then save it back, so it's 85, and the next time I hit 65 for example, then the purpose of the game is about survival, i.e. to avoid getting hits and stuff. I mean to avoid your HP to reach 0, but I also have to learn how you can implement simple text based organisms by giving your HP access. Thanks

What about using the ini / properties file? Or using JSN?

If you are creating an RPG, save the file while saving the game (HP, MP, item, map (X, Y) etc.)? And the rest of the time should count / calculate those values ​​in memory.

About json

About ini file


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -