D
danielesalatti
Hello!!
I'm studying c++ and I'm trying to get a little piece of code working,
but I'm getting a segfault with strlen here:
void tabhash::set (url *U) {
uint hash = U->hashCode();
char* url = U->giveUrl();
char* chash = (char*)hash;
char* Insert1="INSERT INTO sep_hashtable VALUES (";
char* Insert2=",0,'";
char* Insert3="');";
char* Insert=new
char[strlen(Insert1)+strlen(chash)+strlen(Insert2)+strlen(url)+strlen(Insert3)];
strcpy( Insert, Insert1);
strcat( Insert, chash);
strcat( Insert, Insert2);
strcat( Insert, url);
strcat( Insert, Insert3);
if (mysql_query(&mysql,Insert)) {
cerr << "Cannot insert into sep_hashtable : "
<< strerror(errno) << endl;
exit(1);
}
}
I can't find out why I'm getting this segfault error...can you help me
a bit?
I'm studying c++ and I'm trying to get a little piece of code working,
but I'm getting a segfault with strlen here:
void tabhash::set (url *U) {
uint hash = U->hashCode();
char* url = U->giveUrl();
char* chash = (char*)hash;
char* Insert1="INSERT INTO sep_hashtable VALUES (";
char* Insert2=",0,'";
char* Insert3="');";
char* Insert=new
char[strlen(Insert1)+strlen(chash)+strlen(Insert2)+strlen(url)+strlen(Insert3)];
strcpy( Insert, Insert1);
strcat( Insert, chash);
strcat( Insert, Insert2);
strcat( Insert, url);
strcat( Insert, Insert3);
if (mysql_query(&mysql,Insert)) {
cerr << "Cannot insert into sep_hashtable : "
<< strerror(errno) << endl;
exit(1);
}
}
I can't find out why I'm getting this segfault error...can you help me
a bit?