Ejercicio sobre punteros #47
martinvilu
started this conversation in
General
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Punteros
Escribir un programa corto en
C
que declare e inicialice a cualquier valor deseado, sin ser necesario que sea ingresado por el usuario, variables de tipodouble
,int
ychar
. A continuación, declare e inicialice un puntero a cada una de las tres variables. Su programa debe imprimir la dirección y el valor almacenado y el tamaño de la memoria (en bytes) de cada una de las seis variables.Utilice el especificador de formato "
%p
" para imprimir direcciones de punteros (las cuales están en hexadecimal).Para obtener los tamaños en memoria de las variables, utiliza el operador
sizeof
para determinar el tamaño de memoria asignado para cada variable.Para armar la salida en columnas, pueden usar tabuladores
\t
en la cadena de format delprintf
.Salida esperada
La notación
0x
se utiliza para indicar que el número a continuación está en base 16, hexadecimal. De la misma manera que los literalespara números enteros en esta base.
En donde el primer espacio es para el nombre de la variable
Más sobre direcciones de memoria.
¿Como son las direcciones de memoria en el código?
Beta Was this translation helpful? Give feedback.
All reactions