Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Link Between Pointer and Variable | Pointers Fundamentals
C++ Pointers and References

book
Link Between Pointer and Variable

When you modify the value through the dereferenced pointer, you are essentially modifying the content of the memory location it points to. This directly affects the original variable.

Remember

Changing the value through *(p_variable) is equivalent to changing the value of variable.

Tarea

Swipe to start coding

  1. Declare and initialize the pointer with a variable address.
  2. Change the value of dereferenced pointer to zero.
  3. Output the variable value.

Solución

cpp

solution

#include <iostream>

int main()
{
float variable = 10;
float* p_variable = &variable;

*p_variable = 0;

std::cout << variable << std::endl;
}

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 3
#include <iostream>

int main()
{
float variable = 10.2;
___ _ p_variable = _ ___;

_ ___ = 0;

std::cout << variable << std::endl;
}

Pregunte a AI

expand
ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

some-alt