I've been at a loss as how to convert the std::string to char (Line 40). I've tried c_str() and a few other things, but it's really confusing when the pointers are thrown in there. I know I'm kind of asking you guys to do it but I don't know what else to do :/.
#include <iostream>
#include <string>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <new>
#include <string.h>
using namespace std;
bool fileExists(const char *fileName)
{
ifstream infile(fileName);
return infile.good();
}
int main ()
{
vector <string> GNames;
vector <string> GAliases;
if ( fileExists("GName.txt") == 0 || fileExists("GAlias.txt") == 0 )
{
cout << "Title of 'Name' file should be: GName" << endl;
cout << "Title of 'Alias' file should be: GAlias" << endl;
cin.get();
} else {
string fileline;
ifstream tstream("GName.txt", ifstream::in);
if (tstream.good())
{
while (!tstream.eof())
{
getline(tstream, fileline);
char * str;
str = new char (fileline);
char * pch;
pch = strtok (str," ");
while (pch != NULL)
{
pch = strtok (NULL, " ");
GNames.push_back(pch);
}
}
tstream.close();
} else {
cout << "ERROR 101: Can't open file" << endl;
}
cout << "Game generation completed" << endl;
cin.get();
}
return 0;
}