sprintf 用法

常用来进行格式化sql语句,示例如下:
char sql[1024] = {0};
unsigned int total_len = 0;
 unsigned int len = sprintf(sql,"replace into %s.%s (uid) values ",\
  dbname,tablename);
 total_len = len;
 for(unsigned int i = 0; i < vv_size; i++)
 {
  if(i > 0)
  {
   len = sprintf(sql+total_len,"%c",',');
   total_len += len;
 }

}


 

你可能感兴趣的:(sprintf 用法)