Abl-electronic PIC Microcontrollers PIC16 Manuel d'utilisateur Page 120

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 312
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 119
Sizeof Operator
Prefix unary operator sizeof returns an integer constant that gives the size in
bytes of how much memory space is used by its operand (determined by its type,
with some exceptions).
Operator
sizeof can take either a type identifier or an unary expression as an
operand. You cannot use
sizeof with expressions of function type, incomplete
types, parenthesized names of such types, or with an lvalue that designates a bit
field object.
Sizeof Applied to Expression
If applied to expression, size of the operand is determined without evaluating the
expression (and therefore without side effects). Result of the operation will be the
size of the type of the expression’s result.
Sizeof Applied to Type
If applied to a type identifier,
sizeof returns the size of the specified type. Unit
for type size is the sizeof(char) which is equivalent to one byte. Operation
sizeof(char) gives the result 1, whether the char is signed or unsigned.
sizeof(char)
/* returns 1 */
sizeof(int)
/* returns 2 */
sizeof(unsigned long)
/* returns 4 */
When the operand is a non-parameter of array type, the result is the total number
of bytes in the array (in other words, an array name is not converted to a pointer
type):
int i, j, a[10];
//...
j = sizeof(a[1]);
/* j = sizeof(int) = 2 */
i = sizeof(a);
/* i = 10*sizeof(int) = 20 */
If the operand is a parameter declared as array type or function type, sizeof
gives the size of the pointer. When applied to structures and unions, sizeof gives
the total number of bytes, including any padding. Operator
sizeof cannot be
applied to a function.
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
112
MikroElektronika:
Development
tools
-
Books
-
Compilers
page
Vue de la page 119
1 2 ... 115 116 117 118 119 120 121 122 123 124 125 ... 311 312

Commentaires sur ces manuels

Pas de commentaire