C/C++
CDnGJVLbC5
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
开源项目
文章目录c++ c++ elveldb原创 2021-04-12 13:20:40 · 217 阅读 · 0 评论 -
C++ 拆分字符串为单词的五种方法
本文是对C++ Split string into vector<string> by space- Grandyang 的整理。 方法一: #include <iostream> #include <vector> #include <string> #include <sstream> // istringstream using namespace std; int main() { string str { "dog cat c原创 2020-12-19 15:32:26 · 3930 阅读 · 1 评论 -
C++ size_t 使用注意事项
size_t是一种无符号整数类型 ( unsigned integer types ),因此进行循环时,要十分注意其边界问题. 比如下面这种情况: for ( size_t i = 5; i >=0; --i ) cout << i << " "; 此时,循环是不会自动终止的,因为 size_t 是无符号整型,永远不会出现 i < 0 的情况 ...原创 2020-04-13 18:33:08 · 1158 阅读 · 8 评论 -
C++ pair 与 make_pair
#include <iostream> #include <string> #include <map> using namespace std; int main() { multimap<int, string> stu; // 效果一样 stu.insert( make_pair( 1, "student_one" ) );...原创 2020-04-11 00:28:46 · 203 阅读 · 0 评论 -
C/C++ 经典库函数
经典库函数 1. atoi int atoi( const char* str ) : 把参数 str 所指向的字符串转换为一个整数(类型为 int 型) #include <stdio.h> #include <string.h> // strcpy #include <stdlib.h> // atoi int main() { int v...原创 2020-03-31 16:38:58 · 322 阅读 · 0 评论 -
C++ 判断两个字符串是否相等
#include <iostream> #include <string> #include <string.h> using namespace std; int main() { string str1 = "abc", str2 = "abc"; if ( strcmp( str1.c_str(), str2.c_str() ) == ...原创 2020-03-31 14:28:31 · 3511 阅读 · 2 评论 -
LeetCode C++刷题总结
1 NULL 似乎比 nullptr 更快 19. 删除链表的倒数第N个节点 class Solution { public: ListNode *removeNthFromEnd(ListNode *head, int n) { if (head == NULL || n <= 0) { return NULL; } ...原创 2019-11-04 10:51:39 · 580 阅读 · 0 评论 -
C++ 中 cstring 和 string 的区别
<string>是C++标准库头文件,包含了拟容器 class std::string 的声明(不过 class string 事实上只是 basic_string<char>的typedef,用于字符串操作。 <cstring>是 C 标准库头文件 <string.h>的 C++ 标准库版本。 参考 :https://blog.youkuaiyun.com/q...转载 2019-10-18 15:40:07 · 304 阅读 · 0 评论 -
C++ 指针、空指针、野指针
空指针: C++11中,nullptr代表空指针,尽量使用。 而NULL会被解释为 0 判断空指针 int a = 10; int* p = &a; if(p != nullptr){ // do something } 野指针:未被初始化的指针 ...原创 2019-09-27 10:08:28 · 337 阅读 · 0 评论 -
++i 效率似乎比 i++ 更高
参考:https://blog.youkuaiyun.com/qq_38570571/article/details/81255717 练习 Leetcode时,发现同样的代码,用 ++i比用 i++耗时更少原创 2019-09-27 10:54:40 · 182 阅读 · 0 评论 -
nullptr
nullptr,是c++中空指针类型的关键字 在 C++11中被引入原创 2019-09-29 20:41:32 · 188 阅读 · 0 评论 -
C语言编译多文件
有多个C语言文件,需要一起编译,以下为 gcc实现 // 不指定生成 exe 的名称,默认生成 a.exe 文件 gcc file.h file1.c file2.c // 指定生成 exe 文件的名称,此处为 filename.exe gcc file.h file1.c file2.c -o filename ...原创 2019-10-04 15:41:48 · 528 阅读 · 0 评论 -
C++ struct 的用法
即使通过 typedef将 struct node定义为 list,在后续的使用中,仍然可以再次使用 struct node。从而可以造成一些奇怪的报错。 #include <iostream> #include <stack> using namespace std; typedef struct node { int data; struct node* ...原创 2019-10-05 20:52:33 · 1132 阅读 · 0 评论 -
error: no matching function for call to 'std::exception:exception(const char[15])'
在复现《剑指offer》代码段: throw new exception("queue is empty"); 时,遇到: error: no matching function for call to 'std::exception:exception(const char[15])' 解决方法: #include <stdexcept> std::logic_er...原创 2019-10-07 09:37:50 · 1055 阅读 · 2 评论
分享