생활
c언어 테트리스 랭킹 점수(mysql연동) 해결방법 알려주실수 있나요?
void rank(void) {
system("cls");//화면을 지움
system("mode con: cols=70 lines=40");//콘솔창 크기를 조절
MYSQL* connection = NULL;
MYSQL conn = { 0 };
MYSQLRES* sqlresult;
MYSQL_ROW row = { 0 };
char query[255] = { 0 };
// char name[12] = { 0 };
char score[30] = { 0 };
char id[12] = { 0 };
char passwd[80] = { 0 };
int x = 3;//x좌표 값
int y = 2;//y좌표 값
int num = 0;//순위 변수
int query_stat = 0;
mysql_init(&conn);
connection = mysqlrealconnect(&conn, DB_HOST,
DBUSER, DBPASS, DB_NAME, 3306, (char*)NULL, 0);
if (connection == NULL) {
fprintf(stderr, "error : %s", mysql_error(&conn));
return 1;
}
mysql_query(connection, "select * from log2");//연결이 되면 log2테이블을 불러옴
mysql_query(connection, "select id, score from log2 ORDER BY 3 DESC");//log2테이블에서 내림차순
querystat = mysqlquery(connection, query);
gotoxy(x, y); printf("\t\t아이디\t\t 점수");
y = y + 2;
gotoxy(x, y); printf("=============================================================");
sprintf(query, "insert into log2 value" "(%s, %d)", id, score);//query에 id와 점수를 삽입
mysql_query(connection, query);
sqlresult = mysqlstoreresult(connection);//mysqlstore_result()를 이용하여 연결된 정보를 메모리에 저장
while ((row = mysqlfetchrow(sql_result)) != NULL) {
y = y + 1;
if (num <= 5)
{
gotoxy(x + 5, y); printf("%s", row[0]);
gotoxy(x + 10, y); printf("%10s", row[2]);
}
}
mysqlfreeresult(sql_result);//메모리 해제
_getch();//키의 입력을 받음
while (kbhit()) getch();//키 값을 버림
}
게임이 끝난 점수는 150점인데 저장되는 점수는 20점만 저장이 되서 끝난 점수 그대로 저장이 될려면 어떤부분을 수정해야 하는지, 해결 방법 알려주세요ㅠㅠ
1개의 답변이 있어요!