码迷,mamicode.com
首页 >  
搜索关键字:sizeof    ( 5917个结果
sizeof系列——struct class union
struct:structMyStruct{doublea;charb;intc;};sizeof(MyStrut)=?????很多朋友会认为结果是:8(sizeof(a))+1(sizeof(b))+4(sizeof(c))=13但是当我们在vs上运行输出的结果是16,这是为什么呢?这是编译器为了提高cup的存储速度对一些起始地址进行了"对齐"处理.虽然对齐原则和编..
分类:其他好文   时间:2015-05-10 17:28:45    阅读次数:130
hdu 2512 一卡通大冒险
简单dp dp[i][j]表示i长卡放到j本书里 #include #include #define maxn 2000+5 using namespace std; int dp[maxn][maxn]; void ready() { memset(dp,0,sizeof(dp)); dp[1][1]=1;dp[2][1]=dp[2][2]=1; for(int i=2;i<=2000...
分类:其他好文   时间:2015-05-10 15:46:57    阅读次数:111
poj 2897 Dramatic Multiplications 模拟
//poj 2897 //sep9 #include using namespace std; int ans[128],ansp; int main() { int cases,n,k; scanf("%d",&cases); while(cases--){ memset(ans,0,sizeof(ans)); ansp=0; scanf("%d%d",&n,&k); in...
分类:其他好文   时间:2015-05-10 13:00:38    阅读次数:117
密码验证合格程序
#include #include #include using namespace std; //计算字符串中字符的种类 int calTypeKinds(string &str) { int count[4]; memset(count , 0 , sizeof(int)*4); for(size_t i = 0; i < str.length(); ++i) { if(s...
分类:其他好文   时间:2015-05-10 11:29:38    阅读次数:221
Eratosthenes,筛法求素数
//筛法求区间[0,n]的所有素数,v为素数表 //v[i]==0,i为素数void f(int n) { int m=sqrt(n+0.5); memset(v,0,sizeof(v)); for (int i=2;i<=m;i++) if (!v[i]) for ...
分类:其他好文   时间:2015-05-10 11:19:57    阅读次数:115
12个有趣面试题(C语言)
1.gets()函数 #include int main(int argc, char *argv[]) { char buff[10]; memset(buff, 0, sizeof(buff)); gets(buff); printf("\n The buffer entered is [%s]\n",buff); return 0; }答:上面代码里的问题在于函数gets...
分类:编程语言   时间:2015-05-10 09:52:12    阅读次数:132
实验二 总结
这次的实验,我觉得挺有难度的代码如下:#include#include#include#define getpch(type)(type*)malloc(sizeof(type))#define NULL 0 struct jcb{ char name[10]; //wor...
分类:其他好文   时间:2015-05-10 00:56:19    阅读次数:128
sscanf引发的Heap corruption detected error问题——有待完美解决
抛出问题 今天在写程序的时候遇到了一个以前没有暴露出来的问题,问题如题目所示。下面写了一个小的测试程序,如下: #include #include int main(){ unsigned char *ua = (unsigned char*)malloc(sizeof(unsigned char) * 3); char line[40] = "177 100 88"; ssc...
分类:其他好文   时间:2015-05-09 22:11:11    阅读次数:184
linux内核宏container_of前期准备之gcc扩展关键字typeof
typeof基本介绍 1 typeof(x) 这是它的使用方法,x可以是数据类型或者表达式。它的作用时期和sizeof类似,就是它是在编译器从高级语言(如C语言)翻译成汇编语言时起作用,这个很重要,稍后会解释。 当x是数据类型时,它和关键字typedef很相似,只不过typedef是要先定义再...
分类:系统相关   时间:2015-05-09 19:04:27    阅读次数:248
对指针加1的意义
eg:int a[5]={1,2,3,4,5}; a表示数组首地址,也就是a[0]的地址;a+1表示下一元素的地址,即a[1]的地址; &a表示对象(数组)首地址; &a+1表示下一对象的地址,一个对象有和a一样大小的元素,因此&a+1等价于&a+5*sizeof(int),也就...
分类:其他好文   时间:2015-05-09 17:22:04    阅读次数:107
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!