今日小结

2017-07-24  本文已影响18人  b6aed1af4328

std::string也是以'\0'为终止符的,有小代码为证:


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

int main()
{
        char ch='x';
        std::string str=&ch;
        printf("%s %d\n",str.c_str(),str.size());
        if(str[1]=='\0')
        {
                printf("songshiqi\n");
        }
        str="x";
        printf("%s %d\n",str.c_str(),str.length());
        if(str[1]=='\0')
        printf("songshiqi\n");

}

string的size()和length()均不计'\0'。send时用str.body(),str.length(),接收时务必注意没有'\0'为终止符的,recv的buf要char buf[4096]='\0'做好初始化。
NetBeans的编译在配置里,一项项流程罗列,注意工作目录和执行操作即可。

SET @num:= concat(UNIX_TIMESTAMP(NOW()),'');
SET @colume= 't_market_oneminute_kline_';
SET @colume_name= CONCAT(@colume,@num);
SET @sql_text=CONCAT('create table ',@colume_name,' LIKE t_market_oneminute_kline;');
PREPARE stmt FROM @sql_text;
EXECUTE stmt;

想要变量名作表名建表,忽略了@num需格式转换。主要问题在格式,格式一混,就成blob,成不了。要注意格式转换。

上一篇下一篇

猜你喜欢

热点阅读