wrong return value by mysql_num_fields in C++
Both columns are type varchar(50). And here's what I do:

CString query(SELECT sname FROM mystudents WHERE Sno='nc002';);

if ((return = mysql_query(&dbmaster, query)) != 0)
 {
   exit(1);
}
if ((master = mysql_store_result(&dbmaster)) == 0) {
exit(1);
}
if ((master_fields = mysql_fetch_fields(master)) == NULL) {
exit(1);
}
master_column = mysql_num_fields(master);
//master_column = mysql_field_count(&dbmaster);
mysql_free_result(master);

for (i=0; i<master_column; i++) {
printf ("field %d type is %d", i, master_fields[i].type);
printf ("field %d name is %s", i, master_fields[i].name);
}

This is just a snippet. Every variable is declared correctly. Here,
as expected, I get 2 as the return value for mysql_num_fields or
mysql_field_count. However, in the for loop, I get weird values for
field type and get NULL for second column name:

Field 0 type is 134557680 Field 0 name is column1
Field 1 type is 3239533 Field 1 name is (null)
wrong return value by mysql_num_fields in C++
===

Both columns are type varchar(50). And here's what I do:

CString query(SELECT sname FROM mystudents WHERE Sno='nc002';);

if ((return = mysql_query(&dbmaster, query)) != 0)
 {
   exit(1);
}
if ((master = mysql_store_result(&dbmaster)) == 0) {
exit(1);
}
if ((master_fields = mysql_fetch_fields(master)) == NULL) {
exit(1);
}
master_column = mysql_num_fields(master);
//master_column = mysql_field_count(&dbmaster);
mysql_free_result(master);

for (i=0; i<master_column; i++) {
printf ("field %d type is %d", i, master_fields[i].type);
printf ("field %d name is %s", i, master_fields[i].name);
}

This is just a snippet. Every variable is declared correctly. Here,
as expected, I get 2 as the return value for mysql_num_fields or
mysql_field_count. However, in the for loop, I get weird values for
field type and get NULL for second column name:

Field 0 type is 134557680 Field 0 name is column1
Field 1 type is 3239533 Field 1 name is (null)