I've got a function,
/*
@ ---------------------------------------------
@ string generateCreateTableStatement()
@ called by table.gener...() and it will
@ return something like CREATE TABLE
@ IF NOT EXISTS badge (name=varchar(40) ...)
@ This will allow a table to be created easily
@ ---------------------------------------------
*/
string importTable::generateCreateTableStatement(string db_name){
string statement;
statement += "CREATE TABLE IF NOT EXISTS ";
statement += db_name;
statement += ".";
statement += name;
statement += " ( ";
int i = columns.size() - 1;
while(i > 0){
statement += columns;
statement += " ";
statement += type;
statement += "(";
statement += ((char *) (length[i--]));
statement += "";
if(i > 0){
statement += ", ";
}
}
statement += " ) ";
cout << endl << length[1] << endl;
return (statement);
}
the line
statement += ((char *) (length[i--]));
gives a seg. fault.
length is of type vector<int>
columns and type are both vector<string>
Anyone know how to make this work, and why it's not working? All help is appreciated.
MWB As always, I hope that helped!
Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
/*
@ ---------------------------------------------
@ string generateCreateTableStatement()
@ called by table.gener...() and it will
@ return something like CREATE TABLE
@ IF NOT EXISTS badge (name=varchar(40) ...)
@ This will allow a table to be created easily
@ ---------------------------------------------
*/
string importTable::generateCreateTableStatement(string db_name){
string statement;
statement += "CREATE TABLE IF NOT EXISTS ";
statement += db_name;
statement += ".";
statement += name;
statement += " ( ";
int i = columns.size() - 1;
while(i > 0){
statement += columns;
statement += " ";
statement += type;
statement += "(";
statement += ((char *) (length[i--]));
statement += "";
if(i > 0){
statement += ", ";
}
}
statement += " ) ";
cout << endl << length[1] << endl;
return (statement);
}
the line
statement += ((char *) (length[i--]));
gives a seg. fault.
length is of type vector<int>
columns and type are both vector<string>
Anyone know how to make this work, and why it's not working? All help is appreciated.
MWB As always, I hope that helped!
Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.