
C/C++
alexhilton
欢迎搜索并关注公众号「稀有猿诉」
展开
-
About Error handling in C
C Programming language itself doesnt provide any good mechanism for errorhandling. But standard library and Unix/Linux system calls do provide aconvinient way to handle errors. External varia原创 2009-12-03 19:58:00 · 1790 阅读 · 1 评论 -
为什么仍还用C编码?
作者Andrew Binstock概述:作者论述了C语言仍然屹立不倒,长久不衰的原因:过去C语言在性能和可移植上面有巨大优势,但随着时间的流逝其他语言(C++等)在性能和可移植上与C的差距越来越小.但为什么C还很火.作者认为是因为C语言的简洁性,使它在系统级别上仍然无可替代.但是对于应用程序开发还是选择其他语言较好,因为开发效率更重要.正文:偏好C而非C++的传翻译 2013-03-17 23:16:38 · 4400 阅读 · 0 评论 -
如何用doxygen生成文档
Doxygen是一款基于源代码生成文档的工具,类似于Java中的javadoc.概念:文档和注释的区别文档(Documentation)是给代码的使用者准备的,或者是更高一级的开发者或者是用户,主要是告诉使用者如何更好的使用代码.典型例子就是API文档.注释代码的一部分,解释代码为什么这样写,是给代码的维护者准备的.优秀且可读的代码应该不需要注释,但文档应该是必须有原创 2013-03-07 21:05:52 · 10117 阅读 · 1 评论 -
参数声明中的静态数组索引:一个不错且鲜为人知的C语言特性
C语言的创造者们一定都热衷于让关键字的数目尽可能的少.今天将向你展示另一个可使用C99中static关键字地方.也许你已经看到过在数组的参数声明中包括数组的长度:void foo(int myArray[10]);这样的函数仍可接收整数指针int *,但是长度[10]可以对阅读代码的人们可当作文档,传达着这相函数预期一个长度为10个整数的数组的信息.翻译 2013-02-21 23:04:18 · 3780 阅读 · 0 评论 -
常见面试题之C++
1. struct与C语言中的struct有何区别在C语言中, struct仅用于定义复杂数据结构,也主是说它只能定义数据,它的成员只能是数据类型,不能直接定义方法函数。在C++中,struct除了C中的用途外,还可以像class一样,可以定义成员方法函数。2. struct与class的区别共同点:它们都可以定义面向对象中的类:定义成员数据和成员方法函数。区别原创 2013-02-15 12:15:26 · 2862 阅读 · 0 评论 -
C语言中编译相关的常见错误
1. /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crt1.o: In function `_start':(.text+0x18): undefined reference to `main'collect2: ld 返回 1Reason: no main function in source file2.原创 2013-02-14 09:56:48 · 7451 阅读 · 1 评论 -
如何玩转ELF(*.so)
Shared library can be confusing and erroneous. It is very vulnerable to get "undefined symbols" error. There are some good tools can be used to analyze the so file and help us to locate the error.A.原创 2013-02-13 12:12:01 · 4702 阅读 · 0 评论 -
实战技巧:goto语句的替代实现方式
曾几何时,goto是多么的让牛人绽放他们高超的精湛技术曾几何时,goto又变成了万恶之首曾几何时,goto只在教科书中的示例才会出现有太多的理由不让用goto,但有时,我们又想使用goto的功能,怎么办?用try/catch/finally便可实现同等于goto的功能,来看二个示例:try { // operation one if (failed)原创 2011-10-05 00:12:18 · 17413 阅读 · 2 评论 -
正确的使用语句块
犹记得在初看C,C++和Java的编程书籍时,上面就有介绍语句块,但当时甚是不理解什么是语句块。《代码大全》中也有讲说要把相似功能的语句组织到一起形成语句块,然后与其他语句块用空行分隔。但这只是在人的理解上的语句块,并非是真的程序语言意义上的语句块。程序上的定义,在我的理解来原创 2011-10-13 19:49:06 · 3594 阅读 · 1 评论 -
Multithreading in C and Java
Summary about mutlti-threading in C and Java 1. If the main thread terminates, then the whole program dies, too. So if you want to run som原创 2011-07-13 07:54:29 · 2058 阅读 · 0 评论 -
C++ Revisited
C++ RevisitedI have learnd C++ before and I know C++.But I cannot write any piece of C++ program without compiler's complaints. Itis the tim原创 2011-07-13 07:58:03 · 1750 阅读 · 0 评论 -
Coding Convention for C
1 - Introduction1.1 Why Have Code ConventionsCode conventions are important to programmers for a number of reasons: * 80% of the lifetime cost of a piece of software goes to maintenance.原创 2010-03-10 20:32:00 · 3715 阅读 · 0 评论 -
Visual Studio2005的简介
Visualstudio 2005的一些总结a) 对于Visual studio的每一个工程都有二个版本,一个是调试版本,另一个是发布版本。其中最主要的区别在于调试版本定义了很多用于调试信息的宏,如:_DEBUG,DEBUG等。调试版本主要用于调试,可以很方便的打印LOG信息,查看堆栈信息等等。发布版本则只包含代码所编译生成的二进原创 2010-03-11 12:36:00 · 2408 阅读 · 0 评论 -
how to get internal items from a dialog created from wizard of VC2005
1. It is pretty fast and convinient to create a dialog based application from VC2005s project wizard. But Once you created it, it is very difficult for you to customize it. For e原创 2009-12-03 19:46:00 · 1824 阅读 · 1 评论 -
实战技巧:用Enum(枚举类型)取代整数集
在Android的API中可以发现有很多用整数集来作为参数的地方,先来看一下实例。LinearLayout是大家所熟知的一个UI基本元素,它里面有一个方向的属性,可以通过以下方法来设置: LinearLayout.setOrientation(int);使用的时候,通常都是这样:LinearLayout.setOrientation(LinearLayout.HORIZONTAL原创 2011-10-15 00:09:22 · 7475 阅读 · 6 评论