简体   繁体   English

将MYSQL_TIME数据类型转换为char *或C ++字符串

[英]Convert MYSQL_TIME data type to char * or C++ string

I am using the MySQL C API within a C++ application. 我在C ++应用程序中使用MySQL C API。 I have a column in my result set that is of the type MYSQL_TIME (part of mysql.h). 我的结果集中有一个列,类型为MYSQL_TIME(mysql.h的一部分)。

Is there a way to convert MYSQL_TIME to a char* or to a C++ string? 有没有办法将MYSQL_TIME转换为char *或C ++字符串?

I figured it out: 我想到了:

fprintf(stdout, " %04d-%02d-%02d %02d:%02d:%02d (%ld)\n",
                 ts.year, ts.month, ts.day,
                 ts.hour, ts.minute, ts.second,
                 length[3]);

where length[3] contains the length of ts. 其中length [3]包含ts的长度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM