Apuntadores en C
-
Upload
claudia-rueda -
Category
Documents
-
view
297 -
download
7
description
Transcript of Apuntadores en C
![Page 1: Apuntadores en C](https://reader035.fdocuments.co/reader035/viewer/2022081417/568bf35e1a28ab89339a0fc7/html5/thumbnails/1.jpg)
http://clrueda.docentes.upbga.edu.coClaudia Leonor Rueda Guzmán
ApuntadoresFacultad de Ingeniería Electrónica
![Page 2: Apuntadores en C](https://reader035.fdocuments.co/reader035/viewer/2022081417/568bf35e1a28ab89339a0fc7/html5/thumbnails/2.jpg)
http://clrueda.docentes.upbga.edu.coClaudia Leonor Rueda Guzmán
Definición de un apuntador
• Un apuntador es una variable que contiene la dirección en memoria de otra variable. Se pueden tener apuntadores a cualquier tipo de variable.
![Page 3: Apuntadores en C](https://reader035.fdocuments.co/reader035/viewer/2022081417/568bf35e1a28ab89339a0fc7/html5/thumbnails/3.jpg)
http://clrueda.docentes.upbga.edu.coClaudia Leonor Rueda Guzmán
apuntador
2000 0010 ApuntaG
2001 0007 ApuntaD
2002 X
2003 X
2004 X
2005 X
2006 X
2007 X
2008 X
2009 X
2010 x
0000 34 A
0001 45 B
0002 12 C
0003 4 Var1
0004 99 Var2
0005 -98 Var3
0006 45 Vector1
0007 32 D
0008 55 E
0009 -9 F
0010 3 G
![Page 4: Apuntadores en C](https://reader035.fdocuments.co/reader035/viewer/2022081417/568bf35e1a28ab89339a0fc7/html5/thumbnails/4.jpg)
http://clrueda.docentes.upbga.edu.coClaudia Leonor Rueda Guzmán
Declarar Apuntadores
• int *maria– Declara un Apuntador del tipo entero
• Float *pedro• Char *juan
![Page 5: Apuntadores en C](https://reader035.fdocuments.co/reader035/viewer/2022081417/568bf35e1a28ab89339a0fc7/html5/thumbnails/5.jpg)
http://clrueda.docentes.upbga.edu.coClaudia Leonor Rueda Guzmán
Apuntadores
La dirección de x es 100 y la de y es 200Además la variable ap es en 1000
Declara ap como apuntador
Asigna ap como el apuntador de xEs decir no el valor de x que es 1 sino laDirección de xCual valor tendría entonces?
![Page 6: Apuntadores en C](https://reader035.fdocuments.co/reader035/viewer/2022081417/568bf35e1a28ab89339a0fc7/html5/thumbnails/6.jpg)
http://clrueda.docentes.upbga.edu.coClaudia Leonor Rueda Guzmán
Ejemplo en c
![Page 7: Apuntadores en C](https://reader035.fdocuments.co/reader035/viewer/2022081417/568bf35e1a28ab89339a0fc7/html5/thumbnails/7.jpg)
http://clrueda.docentes.upbga.edu.coClaudia Leonor Rueda Guzmán
Análisis del ejemplo
![Page 8: Apuntadores en C](https://reader035.fdocuments.co/reader035/viewer/2022081417/568bf35e1a28ab89339a0fc7/html5/thumbnails/8.jpg)
http://clrueda.docentes.upbga.edu.coClaudia Leonor Rueda Guzmán
Apuntador de un Caracter
![Page 9: Apuntadores en C](https://reader035.fdocuments.co/reader035/viewer/2022081417/568bf35e1a28ab89339a0fc7/html5/thumbnails/9.jpg)
http://clrueda.docentes.upbga.edu.coClaudia Leonor Rueda Guzmán
Aplicaciones
![Page 10: Apuntadores en C](https://reader035.fdocuments.co/reader035/viewer/2022081417/568bf35e1a28ab89339a0fc7/html5/thumbnails/10.jpg)
http://clrueda.docentes.upbga.edu.coClaudia Leonor Rueda Guzmán
Ejemplo
![Page 11: Apuntadores en C](https://reader035.fdocuments.co/reader035/viewer/2022081417/568bf35e1a28ab89339a0fc7/html5/thumbnails/11.jpg)
http://clrueda.docentes.upbga.edu.coClaudia Leonor Rueda Guzmán
Punteros a Funciones
![Page 12: Apuntadores en C](https://reader035.fdocuments.co/reader035/viewer/2022081417/568bf35e1a28ab89339a0fc7/html5/thumbnails/12.jpg)
http://clrueda.docentes.upbga.edu.coClaudia Leonor Rueda Guzmán
Trabajo con Cadena
![Page 13: Apuntadores en C](https://reader035.fdocuments.co/reader035/viewer/2022081417/568bf35e1a28ab89339a0fc7/html5/thumbnails/13.jpg)
http://clrueda.docentes.upbga.edu.coClaudia Leonor Rueda Guzmán
Getchar y putchar
![Page 14: Apuntadores en C](https://reader035.fdocuments.co/reader035/viewer/2022081417/568bf35e1a28ab89339a0fc7/html5/thumbnails/14.jpg)
http://clrueda.docentes.upbga.edu.coClaudia Leonor Rueda Guzmán
![Page 15: Apuntadores en C](https://reader035.fdocuments.co/reader035/viewer/2022081417/568bf35e1a28ab89339a0fc7/html5/thumbnails/15.jpg)
http://clrueda.docentes.upbga.edu.coClaudia Leonor Rueda Guzmán
Investigar próxima clase
• Como Concatenar dos cadenas de caracteres leídas por teclado
• Leer una cadena de caracteres y generar una nueva al revez.
![Page 16: Apuntadores en C](https://reader035.fdocuments.co/reader035/viewer/2022081417/568bf35e1a28ab89339a0fc7/html5/thumbnails/16.jpg)
http://clrueda.docentes.upbga.edu.coClaudia Leonor Rueda Guzmán
Investigar próxima clase
• Investigar para la próxima Clase las siguientes instrucciones
strncpy Copy characters from string (function)
memcpy Copy block of memory (function)
memmove Move block of memory (function )
memchr Locate character in block of memory (function)
memcmp Compare two blocks of memory (function)
memset Fill block of memory (function)