- 博客(22)
- 资源 (3)
- 收藏
- 关注
原创 Python定时器的一个实现
'''Created on 2012-10-11@author: blh'''import threadingimport timeclass PyTimer: PRECISION = 10 # 10ms def __init__(self, scheduler_num=1): self.lock = thre
2012-10-11 17:10:21 2135
原创 Windows环境下用Eclipse+MinGW编译CppUnit的错误解决
在我们编译CppUnit时有可能遇到下面的错误#error Cannot define CppUnit::OStringStream在你的project的Properties->C/C++ Build/Setting/GCC C++ Compiler/Preporcessor加入预定义宏CPPUNIT_HAVE_SSTREAM然后在编译,就可以编译通过生成静态或者动态C
2012-05-24 07:13:01 1243
原创 C++虚析构函数
当释放类对象指针时,会调用类析构函数,但如果释放的基类指针是属于其派生类对象的,这种行为未定义,为了保证派生类的析构函数也被调用,需要将基类析构函数定义为虚。例子://1. 基类使用虚析构函数 (基类为A)#include using namespace std;class C {public: C() { cout
2011-12-24 16:58:45 514
原创 设置Qt应用程序图标
给你的应用指定了一个图标icon.ico,但编译执行后任然是系统图标可以使用下面方法设置应用图标创建资源文件:qt.rc (VS的资源文件语法),内如如下IDI_ICON ICON DISCARDABLE "icon.ico"然后在应用的
2011-07-09 17:27:43 505
原创 Qt去掉窗口?按钮
通过windowFlags实现setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
2011-07-09 12:51:54 1042
原创 Qt的LineEdit 输入内容控制
默认下,LineEdit接受任何字符输入,如何让LineEdit能偶只接受自定义的输入,如只允许输入XX或者XX.XX(X:0-9)可以使用正则表达式和LineEdit的Validator进行限制例子: QRegExp regExp2("[0-9]{1,2}[.][0-9]
2011-07-09 12:47:49 8194
转载 Makefile 常用函数表
<br />一、字符串处理函数<br />1.$(subst FROM,TO,TEXT)<br />函数名称:字符串替换函数—subst。<br />函数功能:把字串“TEXT”中的“FROM”字符替换为“TO”。<br />返回值:替换后的新字符串。<br /><br />2.$(patsubst PATTERN,REPLACEMENT,TEXT)<br />函数名称:模式替换函数—patsubst。<br />函数功能:搜索“TEXT”中以空格分开的单词,将否符合模式“TAT
2010-08-21 12:56:00 950
原创 用lex和yacc实现的计算器
代码// calc.lex// calc.y// makefile// exam.txt// 使用方法 1$ ./calc // 是用方法2$ ./calc1+31+3=4q$
2010-06-27 12:26:00 1543
原创 一个“回”型数字的程序
#include #define MAX (9)#define MAX_NUM ((MAX) * (MAX))int xy[MAX][MAX];#define m2r(x, y, v) do { while (((x) #define m2d(x, y, v) do { while (((y) #define m2l(x, y, v) do {
2010-05-10 23:24:00 918
原创 VBox下Ubuntu更改分辨率方法
在windows中用VirtualBox (v3.0.2)安装Ubuntu(v9.0.4),默认按照800*600显示,可以采用下列方式更改分辨率 1、加载VBox的Guest Additions2、运行一个终端3、执行su - 更改到root用户 (如果更改失败,先激活root用户)4、编辑/etc/X11/xorg.conf,增加红色字段 Section "D
2009-07-27 21:07:00 5152
原创 用system权限执行程序
今天遇到一个问题,在windows vista中需要手工删除注册表中的一注册项,但该项要求system权限(比administrator权限还高),经过不断努力找到一个程序,在命令行自行命令将regedit.exe按照system权限运行,成功的删除了那个注册表项 命令为 psexec.exe -i -d -s regedit.exe psexec.exe位于工具集 pstoo
2009-07-25 23:39:00 1401
原创 一类出镜率很高的面试题
看看下面代码是否有问题?void getval(int *pi){ int i; pi = (int *)malloc(10 * sizeof(int)); for (i = 0; i { pi[i] = i; }}int main(){ int *pi; int i;
2009-07-22 18:26:00 622
原创 一个C程序例子:打印指定日期所属月的月历
#include #include #include #include int days[6][7];int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};int mdays2[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};#d
2009-07-12 16:48:00 1716 3
原创 判断符号整数和无符号整数的方法
//有符号整数>>操作,符号位不变 #define _is_sign_int(x) ((((x) >> 1) & 0x80000000) ? 1 : 0) #define is_sign_int(x) (((x) > 0) ? _is_sign_int(0 - (x)) : (((x) == 0) ? _is_sign_int((x) - 1) : _is_sign_int(x))
2009-06-18 21:36:00 1485 2
原创 根据结构体某一成员的地址得到该结构体变量的首地址
#define element_to_entity(p,T,e) ((T*)((unsigned char *)(p) - ((unsigned char *)(&(((T *)0)->e))))) 很多人会对((T *)0)很迷糊,其实换个((T *)p) 形式或许更好理解,如果当p的地址为0时就成了((T *)0) 例子#include
2009-06-07 11:04:00 852
原创 几种排序方法的C语言实现
#include #include #define SORT_ASCENDING (1)#if SORT_ASCENDING#define compare_num(a,b) ((a) > (b))#else#define compare_num(a,b) ((a) #endif#define NUM (10)//=======
2009-06-06 23:33:00 1114
原创 加减乘除算24的C代码
#include #define ERROR_NUM (0x7fffffff)#define RESULT_NUM (24)char o_name[] = "+-*/";int calc(int a, int o, int b){if ((a == ERROR_NUM) || (b == ERROR_NUM))return ERROR_NUM;
2009-06-05 09:41:00 1186 1
原创 “搞笑”的C数组5["abcdef"]表示方法
这个形式是正确的,这是由于数组下标的指针定义, 即对于任何两个表达式a 和e, 只要其中一个是指针表达式而另一个为整数, 则a[e] 和*((a)+(e)) 完全一样 如果定义char a[] = "abcdef"即5["abcdef"] 的值等价于"abcdef"[5],a[5]、5[a] 建议这种表达式还是不要用到你的正式代码中,呵呵
2009-06-04 15:26:00 1588 1
一个很有用的工具集 - PsTools
2009-07-25
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人