C
SmartSmall
这个作者很懒,什么都没留下…
展开
-
C——位段
typedef struct AA{short a:3;short b:3;short c:3;}AA;typedef union BB{AA aa;char dat;}BB;int main(int argc, char* argv[]){BB bb;bb.dat = (char)251; //011 111 011print原创 2014-07-17 22:29:31 · 698 阅读 · 0 评论 -
C——通过调用函数分配内存
1)可以在被调用函数中,可以把动态分配的存储位置地址,赋值给指针类型返回值(不同于被调用函数的自动变量地址)。2)如果想把被调用函数中,获得的地址数据传递给调用函数,可以使用指针类型返回值或者二级指针类型 形参(整型传参,取地址)。 1 #include 2 #include 3 4 void fun(int* p){ 5 p = (int*)ma原创 2014-06-29 17:34:50 · 1120 阅读 · 0 评论 -
C——字符串到2-36进制的转换 strtol
long int strtol(const char *nptr,char **endptr,int base);参数base范围从2至36,或0。详见:《strtol百度百科》demo: 1 #include 2 #include 3 4 int main(int argc, char *argv[]) 5 { 6 char *string,*sto原创 2014-12-08 18:01:19 · 1305 阅读 · 0 评论