原创 makefile編譯文件夾下全部程序

廢話不多說 上代碼 CC=g++ INC=/usr/local/include/google/protobuf LIB=/usr/local/lib lib=protobuf SRCS=$(wildcard *.cc *.cp

原创 linux下C連接mongodb

安裝C驅動: http://mongoc.org/libmongoc/current/installing.html 接着添加動態鏈接庫地址 sudo vi /etc/ld.so.conf 增加 /usr/local/lib su

原创 關於listen函數的backlog

unix網絡編程中這樣解釋 曾經指未完成隊列和已完成隊列之和 man listen man 手冊上這樣解釋: The behavior of the backlog argument on TCP sockets chang

原创 pthread_spin自旋鎖

如果互斥鎖被佔用,另一個線程進入時,互斥鎖會引起線程切換。 適合鎖的內容比較多的 自旋鎖,如果鎖被佔用,來了的線程會一直等待直到獲取這把鎖相當於while(1); 適合鎖的內容比較少的 當線程切換的代價遠遠比等待的代價大的時候,使

原创 python爬取電影天堂鏈接並保存mysql

SQL Create database move_db charset=utf8; Use move_db; create table movie_link( id int(11) primary key auto_increme

原创 C++語言基礎(實現string類)

string類的實現 涉及到 拷貝構造函數調用的三種情況 深拷貝淺拷貝 const修飾爲常函數 重載輸出<< 重載賦值運算符= 重載下標運算符[] /* 拷貝構造函數調用的三種情況? 1.用一個對象初始另一個對象 2.用對象作

原创 C++語言基礎_const

#include <iostream> using namespace std; class test{ int v; const int con;//不允許改變 public: test(int i,int c):v

原创 手寫雙向鏈表

/* *不帶頭的鏈表 **/ #include <stdio.h> #include <stdlib.h> struct node { int var; struct node* prev; struct

原创 解決從Windows拷貝來的文件到Ubuntu出現亂碼 iconv -f gbk -t utf8 book.c > book2.c iconv -f gbk -t utf8 testHTTP.cpp

解決從Windows拷貝來的文件到Ubuntu出現亂碼 iconv -f gbk -t utf8 book.c > book2.c iconv -f gbk -t utf8 testHTTP.cpp > testHTTP2.cpp

原创 基類派生類類型轉換以及虛函數

#include <iostream> using namespace std; class A{ protected: int a; public: A(){ cout<<"A()"<<endl; }

原创 使用protobuf的socket例子

peop.proto package pck; message People{ required string name=1; required int32 id=2; requi

原创 第一題:將連續重複的字母壓縮,一個單獨字母不變。如輸入aabcccc,輸出a2bc4第二題:輸入一系列座標,求出這些座標在一條直線上的最多座標的數量。如輸入(1,1),(2,2),(3,3),(4,

作者:我要拿offer~ 鏈接:https://www.nowcoder.com/discuss/305915?type=post&order=create&pos=&page=1 來源:牛客網 一共3題,90分鐘。語言要求:

原创 UDP server/client實例

#include<stdio.h> #include<stdlib.h> #include<sys/socket.h> #include<arpa/inet.h> #include<unistd.h> #include<strin