码迷,mamicode.com
首页 >  
搜索关键字:sizeof    ( 5917个结果
new总结
引子:写C的人有个好习惯,就是if(malloc(sizeof(int)) == NULL) 申请完之后会检查一下,那么c++里你或许也会自然而然的有个好习惯if(new int[SIZE] == NULL) ,但这样无补于事,因为这个new并不等效于malloc,这里如果失败了就抛出badallo...
分类:其他好文   时间:2015-05-23 11:20:41    阅读次数:111
确定主机字节序
#include int main(int argc, char **argv) { union { short s; char c[sizeof(short)]; } un; un.s = 0x0102; if (sizeof(short) == 2) { if (un.c[0] == 1 && un.c...
分类:其他好文   时间:2015-05-23 00:04:24    阅读次数:114
笔试题
题一:unsignedchar*p1;unsignedlong*p2;p1=(unsignedchar*)0x801000;p2=(unsignedlong*)0x810000;请问p1+5=什么?p2+5=什么?801005810005801010810014801005810014801010810015回答:1代表的是一个单位量p1+5=p1+5*1=p1+5*sizeof(unsignedchar)=p1+5*1=0x801000+ox5=0x801005..
分类:其他好文   时间:2015-05-22 02:02:35    阅读次数:162
iOS录音后播放声音小,AudioSessionInitialize failed,AudioQueueStart failed (-50)
方法1:UInt32 audioRoute = kAudioSessionOverrideAudioRoute_Speaker;AudioSessionSetProperty(kAudioSessionProperty_OverrideAudioRoute, sizeof(audioRoute), ...
分类:移动开发   时间:2015-05-22 01:45:21    阅读次数:170
实验三 进程调度模拟实验
#include#include#define getpch(type)(type*)malloc(sizeof(type))#define NULL 0struct pcb{ //定义进程控制块PCB char name[10]; //进程名 char state; //状...
分类:系统相关   时间:2015-05-21 22:32:00    阅读次数:304
【持续补充】语法题目
用C++实现一个模版函数,模版函数的功能是求一个数组的元素个数。参考代码:#include #include using namespace std;template int NumOfElement(T (&arr)[n]){ return sizeof(arr) / sizeof(T);}...
分类:其他好文   时间:2015-05-21 19:04:22    阅读次数:122
C++ 空白基类最优化(EBO 或 EBCO)
对于c++中的一个空类  class X { };  事实上并不是空的,sizeof(X)并不等于0, 一般的结果是1。每个X的对象都有一个隐晦的1 bytes,是被编译器安插进去的一个char,这样可以使得这个class的两个objects在内存中配置独一无二的地址。 当X作为另一个类的成员时,如: class A { public:     X x;    ...
分类:编程语言   时间:2015-05-21 12:51:12    阅读次数:137
欧拉函数
《2》 1 //线性筛法求解极性函数(欧拉函数) 2 memset(check, false, sizeof(check)); 3 fai[1] = 1; 4 int tot = 0; 5 for(int i=2; iN) break;15 check[i*peime[j]] = true;...
分类:其他好文   时间:2015-05-20 23:51:00    阅读次数:272
素数高效率筛选法
无需多言直接上代码吧! 1 //Eratosthenes 筛法(埃拉托斯特尼筛法) 2 memset(check, false, sizeof(check)) 3 int tot = 0; 4 for(int i=2; iN) break;21 check[i*prime[j]] ...
分类:其他好文   时间:2015-05-20 22:17:16    阅读次数:227
HDU ACM 4509 湫湫系列故事——减肥记II
分析:这题貌似还可以用线段树做,这里使用memset函数很方便的实现。 #include using namespace std; int main() { int a[1445],i,n,hh,mm; int s,t,count; while(scanf("%d",&n)==1) { memset(a,-1,sizeof(a)); for(i=0;i<n;i++) { ...
分类:其他好文   时间:2015-05-20 09:41:47    阅读次数:112
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!