Saltar al contenido principal
LibreTexts Español

8.4: Matemáticas Puntero

  • Page ID
    82057
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Una de las cosas realmente interesantes de los punteros es la matemática de puntero. Volviendo a nuestro ejemplo de pc en la dirección 3000, si incrementas pc, como en pc++; obtendrás 3001. No es ninguna sorpresa, ¿verdad? Si, por otro lado, tuvieras un puntero a un doble, pd, en la dirección 3000 y lo incrementaras, no terminarías con 3001. De hecho, terminarías con 3008. ¿Por qué? Esto se reduce a lo grande que es la cosa a la que estamos apuntando. los dobles son de 8 bytes cada uno. Si tuvieras un montón de ellos, como en una matriz, incrementar el puntero te daría el siguiente elemento de la matriz. Esto es sumamente útil. Tenga en cuenta que sumar y restar a/de punteros tiene mucho sentido, pero multiplicar, dividir y manipulaciones superiores generalmente no tienen sentido y deben evitarse.


    This page titled 8.4: Matemáticas Puntero is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by James M. Fiore via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.