Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql_row to int

Status
Not open for further replies.

JoSno

Programmer
Apr 11, 2003
45
GB
Hi all,

Got myself a bit stuck using MySQL through the C API.

My code goes :

res = mysql_store_result(&mysql);
row = mysql_fetch_row(res);

now I want it to say something like

mystruct.intvalue = (int)row[0]
mystruct.charvalue = (char)row[1]
etc

but this creates all sorts of errors

Any ideas on how to cast values out of a MYSQL_ROW correctly?

Cheers!
Jo
 
well I've found i can use atoi to sort the first problem out but then how do i convert a mysql_row string to a char?

Cheers!

Jo
 
I suppose you could use [tt]row[1][0][/tt], though I assume there must be a fancier and better way...

//Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top