offset在C语言中使用是什么意思啊?

问题描述:

offset在C语言中使用是什么意思啊?
1个回答 分类:综合 2014-09-17

问题解答:

我来补答
意思是偏移值,通常用于指明一个位置,它的用法是把一个基底位置加上 offset 值 (offset 可以是负数). 例如我们说 : 一个资料结构在内存中的位置是 0x125000,它的 offset 0x10 处是用户名字, offset 0x14 是用户序号.在 PE 结构中, offset 通常用于指明在 exe 档案中的实际位置
在手机的SEEM修改里,Offset就是数值的坐标位置,如:offset64就是指左边的横坐标0x060(行),上边的纵坐标x04(列);offset1E,就是指左边的横坐标0x010(行),上边的纵坐标x0E(列).
lrc歌词中会经常见到[offset:500]这样的说明,指的是卡拉OK歌词滚动时的偏移量
C语言中的宏定义:
offsetof (type,member)
返回值:2个地址的偏移量,第一个地址是结构体名字,第二个地址是结构体成员,
所以返回的是二者之间的以byte为单位的偏移量
由于c++中struct已经强化为类,the use of offsetof is restricted to "POD types".
例子:
/* offsetof example */
#include
#include
struct mystruct
{
char singlechar;
char arraymember[10];
char anotherchar;
};
int main ()
{
printf ("offsetof(mystruct,singlechar) is %d\n",offsetof(mystruct,singlechar));
printf ("offsetof(mystruct,arraymember) is %d\n",offsetof(mystruct,arraymember));
printf ("offsetof(mystruct,anotherchar) is %d\n",offsetof(mystruct,anotherchar));
return 0;
}
Offset:引用函数,可以引用区域和单元格
语法:=Offset(reference,rows,cols,height,width)第一个参数是原点,第二个参数是
偏移的行,第三个参数是偏移的列,第四个参数是行高,第五个参数是列宽
 
 
展开全文阅读
剩余:2000