Renesas TM V.3.20A Especificaciones Pagina 98

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 762
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 97
Renesas Technology, Tools FAQs
Last Updated: July 5, 2001
Document Number: 01062001_e
Q.
I made the following program in C.
if (x++ == 5){
aaasub();
}
Upon examining the generated codes, it seems that variable x (the operand) is compared with 5 before the variable increment. Is the
following description necessary in order to have variable x compared with 5 after the variable increment?
x++;
if (x ==5){
aaasub();
}
A.
There are two ways to use the increment (++) and decrement (--) operators: preceding the operand (pre-) or following the operand
(post-).
pre-increment / pre-decrement: Increment or decrement operator precedes the variable (the operand).
post-increment / post-decrement: Increment or decrement follows the variable (the operand).
The program you made uses a post-increment, and the comparison of variable x and 5 is performed before the variable increment.
To perform the desired operation, you have to use a pre-increment for variable x.
if (++x == 5){
aaasub();
}
Top of Page | Back to Previous Page
Terms of Use Privacy Policy
(C)2004 Renesas Technology Corp., All Rights Reserved.
Vista de pagina 97
1 2 ... 93 94 95 96 97 98 99 100 101 102 103 ... 761 762

Comentarios a estos manuales

Sin comentarios