原文 功能: 首先,sizeof(int)肯定是2的次方数,比如32位是4,64位是8 ((sizeof(n)+sizeof(int)-1)&~(sizeof(int) - 1) ) 的意思就是,如果sizeof(n)是sizeof(int)的倍数,则保持不变,否则返回最小的,大于sizeof(n)的,sizeof(int)的倍数.比如,如果sizeof(int)是4,那么sizeof(n)是1-4的时候返回4,5-8的时候返回8,以此类推 实现: 首先sizeof(int)写成2进制是1后面若…
小问题,暂时记录注意一下   printf("sizeof(int): %d\n", (int)sizeof(int));     printf("sizeof(int *): %d\n", (int)sizeof(int *));…
这一段程序 下面这段程序很有看点://arr1 is an array of intsint *source=arr1;size_t sz=sizeof(arr1)/sizeof(*arr1);//number of elementsint *dest=new int[sz];while(source!=arr1+sz)    *dest++=*source++;//copy element and increment pointers 1.source是一个指向数组arr1的第一个元素的指针.…
This interview question come from a famous communication firm of china. : ) #include <iostream> #include <stdio.h> #include <string.h> #include <conio.h> using namespace std; int main() { float a = 1.0f; cout << cout <<…
#include <iostream>#include <stdio.h>#include <string.h>#include <conio.h>using namespace std; int main(){float a = 1.0f; cout << sizeof(int) <<endl;//4cout << sizeof(float) <<endl;//4 cout << (int)a &…
(int)a.&a.(int)&a.(int&)a的区别,很偏僻的题 #include <iostream> #include <stdio.h> #include <string.h> #include <conio.h> using namespace std; int main() { float a = 1.0f; cout << sizeof(int) <<endl;//4 cout <<…
1)问题:二级指针到底是什么?怎么用的?怎么存放的? #include <stdio.h> #define TEST_ADDR 0x12FF40 void main() { int a = 0x5555AAAA; int* pA = &a; int** ppA = NULL; unsigned int * pAddr = (unsigned int *)TEST_ADDR; ppA = &pA; printf("0x%p\n",a); printf(&quo…
int *p()是返回指针的函数 int (*p)()是指向函数的指针   返回指针的函数: int *a(int x,int y); 有若干个学生的成绩(每个学生有4门课程),要求在用户输入学生序号以后,能输出该学生的全部成绩.用指针函数来实现. #include <iostream> #include <stdio.h> #include <vector> #include <string.h> using namespace std; #define…
转自:http://paddy-w.iteye.com/blog/1403217 在Linux操作系统下使用GCC进行编程,目前一般的处理器为32位字宽,下面是/usr/include/limit.h文件对Linux下数据类型的限制及存储字节大小的说明.  /* We don't have #include_next.   Define ANSI <limits.h> for standard 32-bit words.  */     /* These assume 8-bit 'char'…
用过C的人都知道每一个C的程序都会有一个main(),但有时看别人写的程序发现主函数不是int main(),而是int _tmain(),而且头文件也不是<iostream.h>而是<stdafx.h>,会困惑吧? 一起来看看他们有什么关系吧(_tmain()是unicode版本的main()) 首先,这个_tmain()是为了支持unicode所使用的main一个别名而已,既然是别名,应该有宏定义过的,在哪里定义的呢?就在那个让你困惑的<stdafx.h>里,有这么…