After some playing around, apparently I have a hidden problem. The compiler thinks I'm trying to input with getline information to a 'char' variable, which I'm not. I think I have something messed up with my dynamic string array.
Here is my full piece of code with the change of how I figured this out.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
int menu;
string Temp;
string owner;
string location;
string date;
int charger;
string serial;
int completed;
int y;
int size = 5;
string* regArray = new string[size];
string NewRegArray[10][5]; //10 as a safegaurd to save often. 5 is Owner, Date, Location Bought, Charger Name, Serial Number.
system ("cls");
cout << "Loading Registry Data Base...";
string tempIn;
ifstream reg;
reg.open("Registry.txt", ios::app);
//if (!reg.is_open()) { cout << "File Currupted or Lost!" << endl; }
//else {
for (int x=0; !reg.eof(); x++){
getline(reg, tempIn); //Owner; Person's name or Business
regArray[0][0] = tempIn;
getline(reg, tempIn); //Location bought from
regArray[x][1] = tempIn;
reg >> regArray[x][2]; //Serial
reg >> regArray[x][3]; //Charger
reg >> regArray[x][4]; //Date
reg >> Temp; //File input fix
string* regArray2 = new string[size];
for (int i = 0; i < size; ++i){
regArray2[i] = regArray[i];}
delete[] regArray;
++size;
regArray = new string[size];
for (int i = 0; i < size - 1; ++i){
regArray[i] = regArray2[i];}
delete[] regArray2;
y++;
// }
}
reg.close();
cout << " DONE!" << endl;
| |
Errors I get is:
1>c:\users\striker\documents\visual studio 2005\projects\serial sorter\serial sorter\addreg.cpp(27) : error C2440: '=' : cannot convert from 'std::string' to 'char'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>c:\users\striker\documents\visual studio 2005\projects\serial sorter\serial sorter\addreg.cpp(29) : error C2440: '=' : cannot convert from 'std::string' to 'char'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
I've been looking around on the internet and where I see examples for dynamic arrays is used with 'int' and 'char', why can't I do this with strings?