If you're pretty sure that space is a good delimiter in your file when you generate it, then perhaps something like this.
Code:
#include<iostream>
#include<fstream>
#include<string>
#include<sstream>
using namespace std;
int main()
{
string line;
string one, two, three;
ifstream load("Gamelist.gl");
while ( getline(load,line) ) {
istringstream is(line);
if ( is >> one >> two >> three ) {
cout << one << "," << two << "," << three << endl;
}
}
}
Everything is a std::string, so no messy char arrays where you have to guess the length is "good enough".
Results
Code:
$ cat Gamelist.gl
1 hello world
2 this_is_a_very_long_string and_this_is_pretty_long_as_well
$ ./a.out
1,hello,world
2,this_is_a_very_long_string,and_this_is_pretty_long_as_well