ifstream f("events.txt");
if (f.is_open())
{
string l,t;
string myArray[5];
int i = 0;
while (getline(f, l))
{
getline(stringstream(l), t, ',');
cout << t << endl;
myArray[i] = t;
cout << myArray[i] << endl;
i = i + 1;
}
So I have a file called 'events.txt' that contains:
An angry orc hits you with his weapon!,-50
A mage casts an evil spell on you!,-20
You found a health potion!,25
An enemy backstabs you from the shadows!,-40
You got eaten by a Dragon!,-1000
This part of the program so far prints out the sentence up to the comma and stores it into an array. My problem is I also want to access the number in some way and store it into another array or to use it when the event occurs, as it'll be used to lower player HP.
Thanks in advance!