- 博客(7)
- 收藏
- 关注
原创 blink不能发,这里记录下
程序被加载到内存中运行,形成进程。进程局部变量和函数调用层级关系会保存在栈中。系统栈空间大小可以通过ulimit -s查看和修改,我目前使用的centos6系统,限值默认为8192k;如果程序中递归层级过深(如递归死循环),会造成栈占用空间超限值引发的崩溃。如果使用gdb打开程序运行,保持程序崩溃时不退出,获得此时异常程序的pid,使用pmap pid命令查看,结果打印中的[ stack ]栏的值就是当前程序占用的栈空间大小。与系统限值比较可以判定是否栈空间超限值导致的问题。一般只有递归逻辑不当,无限递归会
2021-07-02 09:51:22
15055
原创 字符串处理函数
今天做牛客网的输入输出练习时遇到几个函数以前没用过,记录下获取整行输入,空格不截断:getline(cin, input)对于获取的字符串,按照指定字符分割a. 可以使用c的strtok函数,同时指定多个分割符,很吊#include <iostream>#include <cstring>#include <algorithm>#include <vector>#include <string> using namespac
2021-06-20 21:01:02
403
原创 c++ 11中的智能指针使用介绍
c++11 关于auto_ptr智能指针需要引用头文件 <memory>c++ 11不再建议使用auto_ptr,编译时会产生 deprecated(及不赞成) 告警auto_ptr的功能可以被unique_ptr完全替换auto_ptr代码示例#include <iostream>#include <memory>using namespace std;int main(){ auto_ptr<string> p1 (new
2021-05-29 15:54:31
129
原创 多线程生产者和消费者的同步和互斥问题
多线程生产者和消费者的同步和互斥问题定义缓冲区大小为10,三个生产者线程,两个消费者线程,linux下利用互斥和状态变量实现生产者和消费者模型c++代码#include <pthread.h>#include <queue>#include <stdio.h>#include <unistd.h>using namespace std;#define MAX_MSG_LEN 10pthread_mutex_t mutex;pthread_
2021-05-27 17:27:09
325
4
原创 leetcode solution-l03
questionLongest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters.Example 1:Input: “abcabcbb”Output: 3Explanation: The answer is “abc”, with the length of 3.Example 2:Input:
2020-07-09 20:20:47
132
原创 leetcode solution-l02
questionAdd Two NumbersYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.You may ass
2020-07-09 19:59:30
108
原创 leetcode solution-l01
questionGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same element twice.Example:Given nums = [2, 7, 11,
2020-07-09 19:54:22
130
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人