I am trying to determine the field names using the C API using the
example from mysql manual
(http://dev.mysql.com/doc/mysql/en/my...-fields.html):
MYSQL_FIELD *mysql_fetch_fields(MYSQL_RES *result)
Description
Returns an array of all MYSQL_FIELD structures for a result set. Each
structure provides the field definition for one column of the result set.
Return Values
An array of MYSQL_FIELD structures for all columns of a result set.
Errors
None.
Example
unsigned int num_fields;
unsigned int i;
MYSQL_FIELD *fields;
num_fields = mysql_num_fields(result);
fields = mysql_fetch_fields(result);
for(i = 0; i < num_fields; i++)
{
printf("Field %u is %s\n", i, fields[i].name);
}
The manual says that the function returns an array. I ran a query which
returns data in six columns so to my opinion the valid indexes should be
0 upto and including 5. The definition of the variables does not
indicate an array being declared for fields to my opinion. It seems to
ve more like a field definition to me.
The first time I run thel loop (i=0) everything works perfectly, but
when I run the loop for the second time (i=1) the system crashes with an
access violation.
I added a watch to see whether the result was really an array and it
does *not* seem to be an array. Can someone tell me if I do something
wrong or if there could be a bug in the C API functions.
System:
Microsoft Visual C++ 6
Mysql 4.1.11-nt
Thanks in advance!
Jonathan
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?