文章分类 -  C

摘要:先看个例子:#include <stdio.h>#include <stdlib.h>#include <string.h>#include <assert.h>struct helloworld_t{ int num; char helloworld[0];//主要是用来得到一个数组的地址,再由数组的个数来访问};int main(){ struct helloworld_t *p; unsigned int size = sizeof(struct helloworld_t) + strlen("Hello World!\n&quo 阅读全文

posted @ 2012-09-15 23:03 vv1133 阅读(476) 评论(0) 推荐(0) |

摘要:restrict是C99标准中新添加的关键字,对于从C89标准开始起步学习C语言的同学来说(包括我),第一次看到restrict还是相当陌生的。Wikipedia给出的解释如下:In the C programming language, as of the C99 standard, restrict is a keyword that can be used in pointer declarations. The restrict keyword is a declaration of intent given by the programmer to the compiler. It 阅读全文

posted @ 2012-08-11 15:38 vv1133 阅读(728) 评论(0) 推荐(0) |

摘要:转自:瀚海星云 ANSIC版 作者:xhacker一. 不说废话,看代码zjs@xhacker:/tmp$ cat tt.c#include <stdio.h>int main(){ int a = 0x12345678; short *p = (short *)&a; short temp; temp = *p; *p = *(p+1); *(p+1) = temp; printf("%x\n", a);}zjs@xhacker:/tmp$ gcc -O2 tt.czjs@xhacker:/tmp$ ./a.out 12345678zjs@xhacke 阅读全文

posted @ 2012-08-11 15:16 vv1133 阅读(3031) 评论(0) 推荐(0) |

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3