文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>No theme

No theme

时间:2009-08-13  来源:creatory

#!/bin/bash
if ! which awk > /dev/null; then
        echo "Cannot find awk in your PATH!"
        exit 1
fi

if ! which bc > /dev/null; then
        echo "Cannot find bc in your PATH!"
        exit 1
fi

if ! which sed > /dev/null; then
        echo "Cannot find sed in your PATH!"
        exit 1
fi

//this short program is used to test the memory alignment
//char takes up 1 byte,int takes up 4 bytes,short takes up 2 bytes
//but in arm 32-bit architecuture,the current defined data type will determine its memory address by itself and in accord with the previous memory unit.
//struct1:        //struct2
//0x00:i        //0x00:i
//0x01:            //0x01:
//0x02:            //0x02:j
//0x03:            //0x03:j
//0x04:k        //0x04:k
//0x05:k        //0x05:k
//0x06:k        //0x06:k
//0x07:k        //0x07:k
//0x08:j       
//0x09:j   
//0x0a:
//0x0b:
//So,struct1 takes up 12 bytes,struct2 takes up 8 bytes
#include <stdio.h>
struct {
    char i;
    int k;
    short j;
    char n,n1;
}struct1;
struct {
    char i;
    short j;
    int k;
}struct2;
struct {
    int c;
char k,a,b;
short e;
}struct3;
int main(void){
    printf("sizeof(struct1)=%d\n",sizeof(struct1));
    printf("sizeof(struct2)=%d\n",sizeof(struct2));
    printf("sizeof(struct3)=%d\n",sizeof (struct3));
    printf("===================\n");
    printf("%x\n",&struct1.i);
    printf("%x\n",&struct1.k);
    printf("%x\n",&struct1.j);
    printf("%x\n",&struct1.n);
    printf("%x\n",&struct1.n1);
    return 0;
}
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载