MySQL 쿼리에서 가져온 결과를 구조체 배열에 저장하려고합니다. 유형을 제대로 작동시키지 못했고, MySQL 문서를 분류하기가 어려웠습니다.C MySQL 형식 오류
struct login_session
{
char* user[10];
time_t time;
int length;
};
그리고 데이터를 얻기 위해 노력하고있어 루프는 없다 :
내 구조체이다
while ((row = mysql_fetch_row(res)) != NULL) {
strcpy(records[cnt].user, &row[0]);
cnt++;
}
아무리 지속적으로 오류가 내가 그래도 시도 :
test.c:45: warning: passing argument 1 of ‘strcpy’ from incompatible pointer type
/usr/include/string.h:128: note: expected ‘char * __restrict__’ but argument is of type ‘char **’
test.c:45: warning: passing argument 2 of ‘strcpy’ from incompatible pointer type
/usr/include/string.h:128: note: expected ‘const char * __restrict__’ but argument is of type ‘MYSQL_ROW’
모든 포인터?
mysql_fetch_lengths()를 호출하여 결과 내에서 현재 행의 열 길이를 가져온 다음 메모리를 할당하고 내용을 복사 할 수 있습니다. – jfly
감사합니다. 나는 당신의 충고를 받아 포인터에 대한 추가 읽기를 할 것입니다. – Jacobm001