Hi guys,
My first post here and I'm a pascal coder doing his best to move to
C/C++ so please go easy on me ;)
I'm using the MySQL C API to pull some values from a DB. One of the
fields is a float value, but I can't seem to cast this field to a float
variable correctly:-
if(mysql_exec_sql(&mysql,query)==0) /*success*/
{
printf( "%ld Record Found\n",(long) mysql_affected_rows(&mysql));
result = mysql_store_result(&mysql);
if (result) // there are rows
{
num_fields = mysql_num_fields(result);
while ((row = mysql_fetch_row(result)))
{
float total;
total = atof(row[7]);
printf("%-10s", row[7]);
printf("%f", total);
printf("\n");
}
mysql_free_result(result);
}
}
The first one shows the correct value when I show it as a string, the
second one always seems to be "NAN".
I've done some googling around but can't seem to find the answer. I
basically want to grab this field as a float value so that I can do
some maths on it. I beleive this field is, in current form, a string.
Any help would be much appreciated.
Thanks,
Dean