C/C++
Albahaca
这个作者很懒,什么都没留下…
展开
-
Pointers (http://www.cs.cf.ac.uk/Dave/C/node10.html)
SubsectionsWhat is a Pointer?Pointer and FunctionsPointers and ArraysArrays of PointersMultidimensional arrays and pointersStatic Initialisation of Pointer ArraysPointers and StructuresCommon Poin转载 2014-05-24 01:10:39 · 1299 阅读 · 0 评论 -
#if 0
#if 0#endif原创 2014-07-30 08:16:30 · 284 阅读 · 0 评论 -
函数传参:引用类型 vs 指针类型
f (int &a) 引用类型 引用传递f (int *a) 指针类型 (int *指向int型变量的指针类型)值传递在函数里面改变函数外面变量的值1:void f(int &a) {a=4;return;}主函数中:int x=0; f(x);结果 x=42:void f(int *a) {*a=4;return;原创 2013-10-24 06:57:25 · 482 阅读 · 0 评论 -
print uint64_4/uint32_t/uint32_t
#define __STDC_FORMAT_MACROS#include #include int main(){ uint64_t ui64 = 64; uint32_t ui32 = 32; uint16_t ui16 = 16; printf("test uint64_t : %" PRIu64 "\n", ui64);原创 2014-10-02 07:54:47 · 1160 阅读 · 0 评论 -
c bit field
定义data structure时定义成员变量的bit宽度typedef struct example_s { unsigned int data1 : 1; unsigned int data2 : 2;}example_t;参考 http://www.tutorialspoint.com/cprogramming/c_bit_fields.htm原创 2015-03-18 06:31:39 · 335 阅读 · 0 评论 -
c- structure initialization
can define the data structure in one header, initialize in another onecan include header files like this or include both headers in source file without including test_define.h in test_ini.h. but ext原创 2015-03-18 07:06:41 · 357 阅读 · 0 评论 -
c++ container with user defined compare function
1) sort by key:using function pointerbool key_compare(int a, int b){ return (a > b);}int main() { bool(*fn_cmp)(int, int) = key_compare; map m(fn_cmp);}2) sort by value:http://w原创 2015-06-23 16:27:23 · 567 阅读 · 0 评论 -
num->string
C++:int Number = 123;string String = static_cast( &(ostringstream() str();std::string s = std::to_string(42);原创 2015-08-29 04:07:37 · 399 阅读 · 0 评论