原创 C++根據字符提取字符串

int main() {     string url = "http://10.12.2.136:80/api/v3";     string s;     char* str = "http://";     int len = st

原创 104協議格式簡單介紹

APDU = APCI + ASDU APCI:應用規約控制信息(由起始字符+數據長度+控制域)    ASDU:應用服務數據單元(數據格式) APDU:應用規約數據單元   啓動字符68H定義了數據流中的起點。 APDU的長度定義了A

原创 簡單版本的類A回調類B的成員函數

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream> using namespace std; class A; class B {

原创 好代碼是改出來的

好代碼是改出來的,呼應高中語文老師的話:好作文是改出來的

原创 分割字符串,提取數字中的最大值

void split(char str[],char delims[]) {     int max_num = 0;     char *result = NULL;     result = strtok( str, delims )

原创 error出錯處理

當UNIX系統函數出錯時,通常會返回一個負值,而且整型變量errno通常被設置爲具有特定信息的值。在支持多線程的環境中,多個線程共享進程地址空間,每個線程都有屬於它自己的局部error以避免一個線程干擾另一個線程。 對於errno應當注意

原创 簡單模板單例

#include <stdio.h> #include <string.h> #include <stdlib.h> #include <iostream> using namespace std; #define BT_SAFE_DEL

原创 內存釋放多次

#include <iostream> using namespace std;   class A { public:     A(){} }; int main() {     A *a = new A;     /*      *

原创 遇到的問題

1.一直申請內存,沒有釋放內存,導致設備內存不夠用,程序掛掉了。 2.踩內存,導致程序掛掉了。 代碼: #include <stdio.h> #include <string.h> int main() {     int a = 1,

原创 對端主動關閉連接後,recv收的返回值爲0

#include<stdio.h> #include<stdlib.h> #include<string.h> #include<errno.h> #include<sys/types.h> #include<sys/socket.h>

原创 lua中的lua_rawgeti和lua_rawseti函數用法

// gcc a.c -llua5.1#include <lua5.1/lua.h>#include <lua5.1/lualib.h>#include <lua5.1/lauxlib.h>int l_map(lua_State *L){

原创 lua實現文件的copy

function CopyFile(src, dst)    local src_file, err = io.open(src,"r")        if (not src_file) then    

原创 lua加載lua文件

--b.lua local b = {"1234",version = 1, "567"} return b --a.lua local name = "b.lua" local func = loadfile(name)--加載文

原创 lua中的pcall函數例子

--a.luaf = loadfile("b.lua")function fun()    return "hello world"endfunction fun2()end--函數執行成功返回2個值,分別爲true和另外一個函數的返回值

原创 線程簡單操作

#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> void *f1(void *arg) {     printf("hello