
语言(C++/C)
文章平均质量分 88
braveyly
这个作者很懒,什么都没留下…
展开
-
c++和c混合编程
(1)在C++中引用C语言中的函数和变量,在包含C语言头文件(假设为cExample.h)时,需进行下列处理:extern "C"{#include "cExample.h"} 而在C语言的头文件中,对其外部函数只能指定为extern类型,C语言中不支持extern "C"声明,在.c文件中包含了extern "C"时会出现编译语法错误。 笔者编写的C++引用C函数例子工程中包含原创 2008-11-07 20:01:00 · 1705 阅读 · 0 评论 -
lock_code
#include #include int main(){ int fd = open( "./1.txt", O_WRONLY ); if( fd { printf( "Open file 1.txt failed!\n" ); } else { printf( "Open file 1.txt suc原创 2014-04-23 15:50:44 · 872 阅读 · 0 评论 -
C语言的模块仓库
CPAN(Comprehensive Perl Archive Network)就是Perl语言的killer app,1万多位作者编写的12万6千多个模块,让你几乎完成任何任务都能有所凭借,无需从0开始。更早的类似项目还有TeX的CTAN。在CPAN的启发下,PHP语言有PECL和PEAR,Python有PyPI,Ruby有RubyGems,R有CRAN,Node.js有npm,Lua有Lu原创 2013-12-12 12:04:14 · 1219 阅读 · 0 评论 -
C语言几个有意思的问题
1、gets和fgets的区别char *gets(char *s);gets() reads a line from stdin into the buffer pointed to by s until either a terminating newline or EOF, which it replaces with '\0'. No check for buffer原创 2013-12-12 11:44:24 · 1186 阅读 · 0 评论 -
后缀表达式的副作用
#include int main(){ int i = 0; int a[] = {10,20,30}; int r = 1 * a[i++] + 2 * a[i++] + 3 * a[i++]; printf( "%d\n", r ); return 0;}输出为60.C语言标准,最新的是2011年出的C11,之前还有C99。The result of the postfix ++ opera原创 2013-12-12 10:50:30 · 1109 阅读 · 0 评论 -
C语言新标准C11
2011年12月8号,ISO 发布了新的 C 语言的新标准——C11,之前被称为C1X,官方名称 ISO/IEC 9899:2011。 相比C99的变化1. 对齐处理操作符 alignof,函数 aligned_alloc(),以及 头文件 。见 7.15 节。2. _Noreturn 函数标记,类似于 gcc 的 __attribute__((noreturn))。例子:原创 2013-12-12 10:59:25 · 6004 阅读 · 0 评论 -
迟绑定早绑定,迟早都要绑定
1、 概念首先,什么是绑定?( what`s the definition of binding? )c++编程思想上有说到:Connecting a function call to a function body is called binding.(将函数体和函数调用关联起来,就叫绑定)然后,那么什么是早绑定?(Early binding)When bind原创 2010-05-02 13:47:00 · 3470 阅读 · 0 评论 -
类大小sizeof(class)
class如同int等内建类型一样,分配有一定大小的内存,本文通过基本类、含有虚函数的类、单继承的派生类和多重继承的派生类来考察类的内存布局规律。1、普通类对象的大小 //普通类对象的内存布局struct C000{};struct C001{C001() : c_(0x01) {}char c_;};struct C010{原创 2010-05-01 21:52:00 · 1500 阅读 · 0 评论 -
C++继承时子类定义同名成员变量时的调用继承函数的问题
#includeclass Base{public: int a; Base() { a=0; cout<<"I`m base Begin"<<endl; } int Print() { cout<<a<<endl; return 1; }原创 2015-04-16 10:14:40 · 1367 阅读 · 0 评论