Code:
error: cannot convert ‘std::basic_string<char, std::char_traits<char>, std::allocator<char> >’ to ‘char’ in initialization
i get the above when i try to compile this:
Code:
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int count = 0;
ifstream infile("/home/babag/Documents/Scripts/ScriptVariables.txt");
vector<string> ScriptVariables;
string line;
while (getline(infile, line))
{
ScriptVariables.push_back(line);
}
infile.close();
char headerA = ScriptVariables[000];
cout << ScriptVariables[000] << endl;
cout << headerA << endl;
return 0;
}
with help from those here i've gotten this to read each line of
a text file to an array, ScriptVariables[n].
i now want to reassign each of these array elements to another
variable with a friendlier name. that's what i'm trying to do
with:
Code:
char headerA = ScriptVariables[000];
but it gives me the error. this is just the first of a hundred,
or so, of these ScriptVariables[n] i'll reassign to new names.
also, some should be strings, some numerical. i assume there's
a way i can differentiate or convert them when i reassign the
new names?
thanks again for all the help,
BabaG