#include
#include
#include
using namespace std;
int main()
{
char Sql[512] = { 0 };
int a1 = 15;
int a2 = 1;
int a3 = 1469119980;
int a4 = 1469119980;
const char* s1 = "/export/home/process/PM/ftp/yypmhw/";
const char* s2 = "BSC3-60-201607212300-201607220000-20160722005000.csv";
const char* s3 = "0";
snprintf(Sql, sizeof(Sql), "insert into tp_get_pmfile_config(mo_type_id,file_dir, file_name, vendor_name,state,create_time,gather_time) "
"values(%d,'%s', '%s', '%s', %d, %ld,%ld)", a1, s1,s2,s3,a2,/*time(NULL)*/a3, a4);
cout<< Sql <<endl;
return 0;
}
输出结果在32位主机上面可以正常输出,但是在64位主机上面会乱码,是最后的占位符导致的,%ld,如果换成%d的话可以正常输出,但是不明白的是字节小的不是可以往大的地方存么