I am looking to make a small program that will cut down the repetetive need to insert BB tags in to achievements lists on a site I work for.
So far I have got the algorithm sucessfully reading the first line of the file, and outputting it using cout. The part im having difficulty with is reading all the lines underneath while combining them with the BB tags.
So far I have
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string name;
int points;
string description;
ifstream inFile;
inFile.open("C:\\Users\\Andy\\Desktop\\codegen.txt");
if (!inFile) {
cout << "Unable to open file";
exit(1);
}
inFile >> name >> points >> description;
// This is where I get stuck, I know I need a while statement with an EoF argument
// Just most examples use getline, which is not what I want.
while(! inFile.eof()){
cout << "[b]" << name << " - [i]" << points << "[/i][/b]" << endl;
cout << description << endl;
inFile >> name >> points >> description;
}
inFile.close();
return 0;
}
The txt file im reading from will have the following format
Name of achievement points of achievement decription of achievement
Name of achievement points of achievement decription of achievement
Name of achievement points of achievement decription of achievement
The name and the description are strings and need to allow blanks, now is it the txt file im going wrong with or i'm just forgetting a bit of code i was taught :/
Thanks