关闭

Word Boundaries and Slack Byte

422人阅读 评论(0) 收藏 举报

        Computer stores structures using the concept of "word boundaries". The size of a word boundary is machine dependent. In a computer with two bytes word boundary, the members of a structure are stored left_aligned on the word boundary, as shown below. A character data takes one byte and an integer takes two bytes. One byte between them is left unoccupied. This unoccupied byte is know as the slack byte.

         When we declare structure variables, each one of them may contain slack bytes and the values stored in such slack bytes are undefined. Due to this, even if the members of two variable are equal, their structures do not necessarily compare equal. C, Therefore, does not permit comparition of structures. However, we can design our own function that could compare individual members to decide whether the structure are equal or not.


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:376795次
    • 积分:4800
    • 等级:
    • 排名:第5979名
    • 原创:118篇
    • 转载:109篇
    • 译文:1篇
    • 评论:43条
    最新评论