zoukankan      html  css  js  c++  java
  • Byte Order, Size, and Alignment

    Byte Order, Size, and Alignment

      By default, C types are represented in the machine’s native format and byte order, and properly aligned by skipping pad bytes if necessary (according to the rules used by the C compiler).

      Alternatively, the first character of the format string can be used to indicate the byte order, size and alignment of the packed data, according to the following table:

      

      If the first character is not one of these, '@' is assumed.

      Native size and alignment are determined using the C compiler’s sizeof expression. This is always combined with native byte order.

      The form '!' is available for those poor souls who claim they can’t remember whether network byte order is big-endian or little-endian.

      

    Notes:

    1. Padding is only automatically added between successive structure members. No padding is added at the beginning or the end of the encoded struct. 
    2. No padding is added when using non-native size and alignment, e.g. with ‘<’, ‘>’, ‘=’, and ‘!’. 
  • 相关阅读:
    Problem B. Harvest of Apples
    字典树的学习
    PACM Team
    2038: [2009国家集训队]小Z的袜子(hose)
    Naive Operations
    C程序设计语言练习 第三章
    数据结构C++实现-第一章 绪论
    排序
    操作系统设计与实现-第一章:序言
    进制转换
  • 原文地址:https://www.cnblogs.com/tekka/p/4548602.html
Copyright © 2011-2022 走看看