?
nach "dem" delete [] temps?
Ich seh da zwei (Zeile 17 und 66).
Was CStoll gesagt hat ist wohl hauptsächlich das Problem, allerdings würds dir auch explodieren, wenn die Eingabe nicht w a s oder d ist. Kleiner fix dafür:
char *qry = "SELECT x,y FROM tabelle WHERE user = '";
char *update = "UPDATE tabelle SET ";
char *temps;
...
// Bewegunsroutine v1
temps = new char[sizeof(qry)+benutzercl.size()+1];
strcpy(temps,qry);
strcat(temps,benutzercl.c_str());
strcat(temps,"'");
mysql_real_query(my,temps,strlen(temps));
results = mysql_store_result(my);
row = mysql_fetch_row(results);
delete [] temps;
ax = atoi(row[0]);
ay = atoi(row[1]);
if(_kbhit) {
eingabe = getch();
}
if(eingabe == 'w' || eingabe == 's') {
temps = new char[sizeof(update)+4+sizeof(row[0])+15+benutzercl.size()+1];
strcpy(temps,update);
strcat(temps,"y = '");
if(eingabe == 'w') {
ay++;
}
if(eingabe == 's') {
ay--;
}
itoa(ay,row[0],10);
strcat(temps,row[0]);
} else if(eingabe == 'a' || eingabe == 'd') {
temps = new char[sizeof(update)+4+sizeof(row[1])+15+benutzercl.size()+1];
strcpy(temps,update);
strcat(temps,"x = '");
if(eingabe == 'a') {
ax++;
}
if(eingabe == 'd') {
ax--;
}
itoa(ax,row[1],10);
strcat(temps,row[1]);
} else {
return; //musst dir eventuell überlegen, was du in einem solchen fall machen solltest, auf jedenfall NICHT weiter den code ausführen.
}
strcat(temps,"' WHERE user = '");
strcat(temps,benutzercl.c_str());
strcat(temps,"'");
mysql_real_query(my,temps,strlen(temps));
delete [] temps;