Documentos de Académico
Documentos de Profesional
Documentos de Cultura
con punteros:
Nodos
y
Listas
Fichas ordenas en orden alfabético y
por otro criterio, usando hilos
: hilo de inicio
: hilo de ficha
: hilo final
struct str {
int x; x p
struct str *p;
};
main(){
struct str a;
struct str *b; Valor entero Dirección a
b=NULL; otra variable
a.x=55;
b=&a;
de misma
b->x=66; estructura
}
Creación de una variable
struct str {
int x; x p
struct str *p;
};
main(){
struct str a;
struct str *b;
b=NULL;
a.x=55;
b=&a;
b->x=66;
}
a
?
x p
Creación de un puntero
struct str {
int x; x p
struct str *p;
};
main(){
struct str a;
struct str *b;
b=NULL;
a.x=55;
b=&a;
b->x=66;
}
a b ?
?
x p
Puntero apuntando a “nada” conocida
struct str {
int x; x p
struct str *p;
};
main(){
struct str a;
struct str *b;
b=NULL;
a.x=55;
b=&a;
b->x=66;
}
a b ?NULL
?
x p
Asignar un valor a un campo
struct str {
int x; x p
struct str *p;
};
main(){
struct str a;
struct str *b;
b=NULL;
a.x=55;
b=&a;
b->x=66;
}
a b NULL
?
55 x p
puntero apuntando a variable
struct str {
int x; x p
struct str *p;
};
main(){
struct str a;
struct str *b;
b=NULL;
a.x=55;
b=&a;
b->x=66;
}
a b NULL
?
55 x p
Cambiando valor por medio de puntero
struct str {
int x; x p
struct str *p;
};
main(){
struct str a;
struct str *b;
b=NULL;
a.x=55;
b=&a;
b->x=66;
}
b a
?
55
66 x p
¿Puntero en “a” apuntar a algo?
struct str {
int x; x p
struct str *p;
};
main(){
struct str a;
struct str *b; •Se puede hacer apuntar a otra variable
b=NULL; del mismo tipo o a “nada” (NULL)
a.x=55;
b=&a;
b->x=66;
}
• La gracia es hacerlo sin usar el
b a
?
nombre de la variable “a” sino el
66 x p puntero “p”
Creando otra variable estructurada
b a d
? ?
66 x p x p
Conectando los nodos
b a d
? ?
66 x p x p
Cerrando la lista
b a d
? ?
NULL
66 x p x p
Dandole valor a x de nuevo nodo
b a d
? NULL
66 x p 77 x p