Pipe is a worm hole connecting C and C++
In C programming language, the observer design pattern is implemented with function pointer (aka callback function). But in Qt library, it introduces signal and slot. How to link a callback function from the C callback function to the C++ siganl and slot is a problem I encounter. Call back function can only be static, but signal and slot can not. There are some triky way to pretend a non-static function to a static function. But the easiest way is to use pipe. the callback function create a pipe and do the read operation, while the siganl function wait for and read at the other end of the pipe.
The pipe is like a worm hole connecting C and C++, two different time and space. How cool!
相关文档:
【原型】
printf("<格式化字符串>
", <参量表>
);
int printf
(const char *format, ...);
int fprintf
(FILE *stream, const char *format, ...);
int sprintf
(char *str, const char *format, ...);
int snprintf
(char *str, size_t size, const char *format, ...);
vp ......
1、 经常看见return EXIT_SUCCESS或return EXIT_FAILURE,但都不知这两个来自何处,现在才知原来stdlib.h定义了EXIT_SUCCESS和EXIT_FAILURE符号。
在stdlib.h头文件里:
#define EXIT_SUCCESS 0
#define EXIT_FAILURE 1
& ......
一、基本知识
指针和引用的声明方式:
声明指针:char* pc;
声明引用:char& rc = 0;
它们的区别:
①从现象上看,指针在运行时可以改变其所指向的值,而引用一旦和某个对象绑定后就不再改变。这句话可以理解为:指针可以被重新赋值以指向另一个不同的对象。但是引用则总是指向在初始化时被指定的对 ......
C/C++中的日期和时间
摘要:
本文从介绍基础概念入手,探讨了在C/C++中对日期和时间操作所用到的数据结构和函数,并对计时、时间的获取、时间的计算和显示格式等方面进行了阐述。本文还通过大量的实例向你展示了time.h头文件中声明的各种函数和数据结构的详细使用方法。
关键字:
UTC(世界标准时间),Calendar Ti ......