Ok I am simply trying to reduce the size of my item data base for this console rpg I am making. I wish to put all the creature names & hp & atk etc in a file then use the ifstream to retrieve this data when I need and place the values in certain variables. I am able to retrieve names, but when it comes to the int's I have problems of conversion.

Here is my test code.

Code:
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main()
{
    ifstream in("happy.txt");
    string line;
    string key = "MONSTER_NAME";
    string two = "Weapon_Name";
    string weaponDamage = "Weapon_Damage";
    string dataSought;
    string weaponName;
    int attack = 0;


   // Read the label "attack" followed by the value
   //_file >> label >> attack;

    while( getline(in, line) )
    {
        //weaponDamage >> attack;
        
        if( key == line.substr(0, key.length()) )
        {
            dataSought = line.substr( key.length()+1 );
            cout << dataSought;
        }
        if( two == line.substr(0, two.length()) )
        {
            weaponName = line.substr( two.length());
            cout << weaponName;            
        }
        if( weaponDamage == line.substr(0, weaponDamage.length()))
        {
                        in >> attack;
              
         }
        }
    
      cout << attack;
    cout << endl;
    system("pause");
}
The test txt file

Code:
xxx ... ... ...
xxz ... ... ...
MONSTER_NAME King Fish Crab
Weapon_Name Zanbato
Weapon_Damage 100
xzz ... ... ...
Now I can display the name of the monster, weapon name, but the attack variable remains unchanged.

Anybody know how to fix this?