1、string转int string str = "1234"; int a; a = stoi(str) > C++11 uint32_t b = stoul(str) > C++11 a = atoi(str.c_str()); { const char *c_str(); c_str()函数 ...
分类:
其他好文 时间:
2017-07-14 21:14:34
阅读次数:
183
fasttext源码剖析 目的:记录结合多方资料以及个人理解的剖析代码; https://heleifz.github.io/14732610572844.html http://www.cnblogs.com/peghoty/p/3857839.html 一:代码总体模块关联图: 核心模块是fas ...
分类:
其他好文 时间:
2017-07-14 00:42:08
阅读次数:
774
在C++中会碰到int和string类型转换的。 string -> int 首先我们先看两个函数: atoi 这个函数是把char * 转换成int的。应该是属于标准库函数。在想把string 转换成int的时候,须要下面流程: string -> char * -> int 如此才干够,样例例如 ...
分类:
编程语言 时间:
2017-07-13 13:26:40
阅读次数:
153
有两个宏可以获取获取编译的时间 __DATA__:编译的日期 __TIME__:编译的时间 可以通过打印来看编译的日期和时间: printf("data: %s time: %s",__DATA__,__TIME__); 有时需要将编译的时间放入版本号中,方法如下: #include "stdlib ...
分类:
其他好文 时间:
2017-07-12 20:13:54
阅读次数:
449
题目 URL:https://leetcode.com/problems/string-to-integer-atoi 解法 很简单。注意特殊情况,按照如下顺序处理: 这题和上题一样坑爹的是,Leetcode 又没有说异常该如何输出,具体如何输出在上面处理都有说明。 按位计算,时间复杂度O(n),运 ...
分类:
其他好文 时间:
2017-07-12 01:11:46
阅读次数:
146
今天打开 OneNote,发现里面躺着一篇很久以前写的笔记,现在将它贴出来。 1. 什么叫惊群现象 首先,我们看看维基百科对惊群的定义: The thundering herd problem occurs when a large number of processes waiting for a ...
分类:
其他好文 时间:
2017-07-09 18:30:19
阅读次数:
278
C语言提供了几个标准库函数,可以将任意类型(整型、长整型、浮点型等)的数字转换为字符串。 1.int/float to string/array: C语言提供了几个标准库函数,可以将任意类型(整型、长整型、浮点型等)的数字转换为字符串,下面列举了各函数的方法及其说明。● itoa():将整型值转换为 ...
分类:
编程语言 时间:
2017-06-27 20:04:57
阅读次数:
241
Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below ...
分类:
其他好文 时间:
2017-06-25 17:49:56
阅读次数:
124
技巧一:int-->bool要注意的!bool a=255; bool b= 254; 理论上应该认为a==b,但是根据编译器的不同,结果可能完全不一样 所以更好的写法是 char ch =1; 或者0bool a = (0 != atoi(ch)); 技巧二:将std::string转int,do ...
分类:
其他好文 时间:
2017-06-23 13:35:21
阅读次数:
151
初看貌似有点复杂,可是搞懂了很easy,就一个简单的栈应用,每次遇到计算符号"+", "-", "*", "/"就将栈顶端两个数字出栈,计算后再将结果压栈就可以。。 #include<iostream> #include<vector> #include<stack> using namespace ...
分类:
其他好文 时间:
2017-06-21 18:26:02
阅读次数:
208