Wednesday, August 28, 2013

C MySQL Types Error

C MySQL Types Error

I'm trying to store results taken from a MySQL query into an array of
structs. I can't seem to get the types to work though, and I've found the
MySQL documentation difficult to sort through.
My struct is:
struct login_session
{
char* user[10];
time_t time;
int length;
};
And the loop where I'm trying to get the data is:
while ( (row = mysql_fetch_row(res)) != NULL ) {
strcpy(records[cnt].user, &row[0]);
cnt++;
}
No matter what I try though I constantly get the error:
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'
Any pointers?

No comments:

Post a Comment