
C/C++
文章平均质量分 67
bonny95
行至水穷处,坐看云起时。
展开
-
利用VC设计简易逻辑表达式词法分析器
Normal07.8 磅02falsefalsefalseEN-USZH-CNX-NONEMicrosoftInternetExplorer4<w:LatentSt原创 2008-05-24 11:06:00 · 4124 阅读 · 2 评论 -
c++filt
c++filtdecodes (demangles) low-level names into user-level names so that the linker can keep these overloaded functions from clashing.原创 2011-09-14 11:15:14 · 5934 阅读 · 0 评论 -
RHEL5和RHEL6中的sctp_event_subscribe定义大不同
近来碰到一个关于SCTP的问题:某个产品跑在Monta Vista上,其内核版本号为2.6.21;可每次该产品泡在我们的Red Hat Enterprise Linux 5.5上时,都会报错错误信息如下:^?0 2011-08-16 09:11:57.316267 coolnjm原创 2011-08-24 14:39:13 · 1746 阅读 · 0 评论 -
String Evolver, My First Genetic Algorithm
When reading Evolutionary Computation for Modeling and Optimization[1], I found following problem in section 1.2.3:A string evolver is an evolutionary algorithm that tries to match a reference strin原创 2012-05-04 15:29:32 · 11341 阅读 · 0 评论 -
One-line Tips Recently Summarized
To build C/C++ codes including zlib.h, gcc flag "-lz" must be added, such as gcc -o kseq -lz kseq.h kseq_test.cTo check if some file/dir is affected by SELinux, use command "ls -Z xxx".To change the s原创 2012-09-15 03:20:09 · 3924 阅读 · 0 评论 -
An Implementation of Merge Sort in C
Following C code is the implementation of merge sort, with the time complexity of O(nlogn). It was used in my current project to sort 148 million integers. At first I used bubbled sort, which took me原创 2012-11-04 21:09:26 · 846 阅读 · 0 评论 -
Calculate the CDF of Poisson Distribution with Boost C++ Library
The Cumulative Distribution Function(CDF) of Poisson distribution can be easily calculated by R function ppois() or octave/Matlab function poisspdf(). However, it is not a easy thing to deal with stat原创 2012-11-06 07:11:33 · 1853 阅读 · 0 评论 -
Basic Linux Multi-Process & Multi-Thread Programming
Today I have to make my algorithm running in parallel in order to make it faster. At first I used following way to implement multi-process: unsigned int proc_num = 5; pid_t* pids=new pid_t[proc_num原创 2013-01-30 11:31:52 · 1155 阅读 · 0 评论 -
Implementation of Strassen’s Algorithm for Matrix Multiplication
Strassen’s algorithm is not the most efficient algorithm for matrix multiplication, but it was the first algorithm that was theoretically faster than the naive algorithm. There is very good explanatio原创 2013-03-21 06:25:05 · 1285 阅读 · 0 评论 -
Linear Space Sequence Alignment
For explanation to linear space sequence alignment, please refer to http://ai.stanford.edu/~serafim/CS262_2007/notes/lecture3.pdf. The algorithm and equation I used was from the textbook Algorithm D原创 2013-04-06 05:53:24 · 1261 阅读 · 0 评论 -
Build Dense Trajectory Codes in Ubuntu
Even when the OpenCV and ffmpeg have been successfully installed, you still may meet the error of "undefined reference to main" when building the Dense Trajectory code. Since the author didn't provide原创 2013-10-11 06:50:34 · 1474 阅读 · 1 评论 -
利用VC绘制对数坐标系
利用VC绘制对数坐标系目标:绘制以任意频率为起点、任意频率为终点的对数坐标,并能对坐标进行任意缩放。实现方法:1、定义标准频率:频率值为10N的相应的频率点,其中N=…-2,-1,0,1,2,3…,单位MHz。如0.01MHZ、0.1MHz、1MHz、10MHz、100MHz等都是标准频率。2、思路 首先找出标准频率,画出标准频率线,然后根据标准频率原创 2008-02-21 14:28:00 · 7790 阅读 · 8 评论 -
C++ Code to Print Pascal Triangle
Printing Pascal Triangle seems like an easy problem, however, it is not that easy to print a good-looking Pascal Triangle. To print the Pascal Triangle, for each line, first print spaces to the left原创 2014-03-27 00:46:57 · 823 阅读 · 0 评论 -
pthread_exit() in main()
Most threads call pthread_exit() implicitly on return from the thread start routine. Besides, pthread_exit() also can be used to terminate the initial process thread in main(), leaving other threa原创 2014-11-21 14:13:44 · 2392 阅读 · 0 评论 -
Linux System Log
Overviewprintkklogdsyslogdmesgsyslog-ngConvert Timestamp1. OverviewLinux adopts a ring buffer in kernel with a size of __LOG_BUF_LEN bytes to store system logs, where __LOG_BUF_LEN equals (1原创 2015-01-13 07:52:08 · 2980 阅读 · 0 评论 -
Click Notes I - Overview
Click is a modular router toolkit written mainly in C++, which can be run in both user space and OS kernel space. Since its invention in late 1990s by Eddie Kohler, Click is has gained great success原创 2014-12-24 06:01:28 · 2314 阅读 · 0 评论 -
C/C++ 位域(Bit Fields)
<br />今天中午与同事讨论位域的问题,越讨论越迷糊,最终还是求救Google,找到一些文章,把比较好两篇的转载于下。<br /> <br /> <br /> <br />1. 原文:http://www.cs.cf.ac.uk/Dave/C/node13.html<br /> <br /><br /> We have seen how pointers give us control over low level memory operations.<br />Many programs (e.g. s转载 2011-03-03 13:52:00 · 1627 阅读 · 0 评论 -
[转]项目中用到的dbx命令的简单使用方法
原文地址:http://blog.youkuaiyun.com/monster_ll/archive/2007/04/05/1553377.aspx dbx是unix下普遍的源码调试工具, 掌握好了dbx的使用,无疑象增添了unix下编程的一把利器研究了一下午dbx的连机文档,发现dbx很是简单易用现在简单介绍一下dbx的使用方法,让更多的朋友免去独自研究的苦楚dbx主要用来调试用f77或cc等编译工转载 2009-12-23 12:16:00 · 969 阅读 · 0 评论 -
【总结】Linux下C开发,怎么做成库文件,又怎么引用这个库文件?
本文根据http://topic.youkuaiyun.com/u/20091026/10/0e913e37-e4a2-4504-bcc7-61af18a22dde.html?6487的回复总结而成。 1. 共享库 通常做成共享库的话,在编绎时加上-shared参数,并把链接生成的文件名命名libxxx.so,可以放在/usr/lib下 其他程序引用这个库时,在链接的时候加上-lxxx就可以了原创 2009-10-27 15:01:00 · 3466 阅读 · 0 评论 -
线性坐标系到对数坐标系的变换——EMC测试曲线的绘制
Normal07.8 磅02falsefalsefalseEN-USZH-CNX-NONEMicrosoftInternetExplorer4<w:LatentSt原创 2008-05-23 00:03:00 · 8100 阅读 · 0 评论 -
逻辑表达式词法分析器分析结果的显示
上篇博客文章《简易逻辑表达式词法分析器》讲到设计了一个逻辑表达式词法分析器,这次以那个词法分析器作为后端,利用VC搭建前端界面,展示一下分析效果。 分析结果以树的形式表示:同一级节点表示具有相同的等级,参数比它的谓词的等级要高,比如Missile(x)中Missile等级为0级,x为1级。分析之后各个节点存储在Parser.list中,可以根据该链表的节点的level属性将各原创 2008-05-27 00:45:00 · 2003 阅读 · 0 评论 -
C语言函数中定义大数组耗尽堆栈的问题
今晚上一同学请我帮忙看一个C程序,GCC编译时一直抱错,说是段错误。程序本身写的比较差,但编译能通过,只是有几十个警告。两个小时过去了,在Eclipse+GCC下没有找到问题(这个环境还不熟悉),换到了VC下面,逐步调试,才发现问题出在被main调用的一个叫做readmctal()的函数的前面几行中。该函数如下:void readmctal(void){ int number,count,s原创 2008-08-26 23:22:00 · 8629 阅读 · 3 评论 -
EMC-CBR故障诊断研究(四)
Normal07.8 磅02falsefalsefalseEN-USZH-CNX-NONEMicrosoftInternetExplorer4<w:LatentSt原创 2008-06-05 15:29:00 · 1282 阅读 · 0 评论 -
类成员函数指针浅析
今天看某软件的源代码时,发现有这样一行typedef CPB_RETVAL (CPBprb_Prb::*CPBprb_action)(CPBprb_Prb &, unsigned);其中CPB_RETVAL是一个enum类型,CPBprb_Prb是一个类,CPBprb_action在代码中其他地方没有找到定义。因不知这行代码所为何意,遂在论坛发贴请教http://topic.youkuaiyun.com/u/原创 2008-09-08 18:29:00 · 734 阅读 · 0 评论 -
函数对象
看到有个概念叫“函数对象”,搜了一下关于它的解释: 函数对象(function object),又名仿函数(functor),是重载了operator()的一个类,其实在stl算法中有大量运用,c++标准预定义的如less ,bind2nd 为什么引入仿函数? 原因: 1.仿函数有具体型别,可用在模板参数,而函数不行 2.同类仿函数可有不同植,原创 2008-09-08 19:49:00 · 644 阅读 · 0 评论 -
7月4日
7月4日,美国的国庆节。 7月4日,大陆和台湾之间的旅游包机即将直航。 7月4日,我将正式去公司入职,开始我人生的第一份全职工作。PS: 不知道是不是ASP.NET对Linux支持有问题,我在Linux下面写博客,写完之后系统总是把整个文章放在一段之中,原有的分段全都不见了。发现在袁萌(极力鼓吹Ubuntu已经到了癫狂状态的一个老头)老师的博客里原创 2008-07-03 20:04:00 · 619 阅读 · 0 评论 -
[转]C++ 运算符优先级列表
C++ 运算符优先级列表http://www.cppreference.com/operator_precedence.html PrecedenceOperatorDescriptionExampleAssociativity1()[]->.::++--Grouping operatorArray accessMember access from a pointerMember access f转载 2008-09-26 21:36:00 · 663 阅读 · 0 评论 -
[转]dbx Command Summary
dbx Command Summary Here is a local copy of short explanation of commands and dbx faq .Basic Dbx Shell Commands!!execute the previous commandrexecute the previous command转载 2009-02-04 23:02:00 · 762 阅读 · 0 评论 -
NULL Pointer Bugs
NULL Pointer BugsA NULL character pointer is NOT the same as a pointer to a NULL string. In Solaris, the following program will lead to a "Segmentation Fault".#include #include int main(){ char *st原创 2008-12-03 20:54:00 · 578 阅读 · 1 评论 -
return (((ulong*)(x))[-1])
看到一个函数,定义如下: #include "u.h"#include "lib.h"ulonggetcallerpc(void *x){ return (((ulong*)(x))[-1]);}((ulong*)(x)) 将void* 的x针针强制转换为 ulong* 此时可以理解为x指向一个ulong类型的数组 [-1] : 表示去x前面的那个元素 上面的代码等价与 ulong px=原创 2008-12-04 14:06:00 · 731 阅读 · 0 评论 -
由服务器名字(Host name)获得IP地址
一下代码可以根据host name获得IP地址:#include #include #include #include #include int main(int argc,char **argv){ struct hostent *hptr; struct in_addr *in_addr_ptr; char *ptr,**pptr,**listptr,*addr_ptr;原创 2008-12-24 22:19:00 · 2193 阅读 · 0 评论 -
[转]在C语言中使用正则表达式
在C语言中使用正则表达式如果用户熟悉Linux下的sed、awk、grep或vi,那么对正则表达式这一概念肯定不会陌生。由于它可以极大地简化处理字符串时的复杂度,因此现在已经在许多Linux实用工具中得到了应用。千万不要以为正则表达式只是Perl、Python、Bash等脚本语言的专利,作为C语言程序员,用户同样可以在自己的程序中运用正则表达式。 标准的C和C++都不支持正则表达式转载 2009-04-11 21:10:00 · 1194 阅读 · 0 评论 -
大数运算
下面这段程序包含了大数的加、减、乘运算的代码,除法运算尚在研究中。 /* * ===================================================================================== * * Filename: LargeNumOp.c * * Description: The re原创 2009-08-24 01:14:00 · 583 阅读 · 0 评论 -
C/C++中使用正则表达式
头文件regex.h中定义了c/c++使用正则表达式的函数: regcomp(), regexec(), regerror(), and regfree() 。regcomp()编译正则表达式,regexec()匹配正则表达式, regfree()释放正则表达式,regerror()报告正则表达式错误信息。使用方法如下代码所示: static string merge_path(cons原创 2009-10-14 10:41:00 · 5444 阅读 · 1 评论 -
Shared-memory Based Ring Buffer
This post explains how to implement a ring buffer that can be shared between multiple processes. For the simplicity and efficiency, shared memory is used to store the ring buffer. A read/write lock原创 2016-07-28 13:19:21 · 2429 阅读 · 0 评论