Created
March 18, 2020 19:56
-
-
Save parzibyte/e70e895a5a6ec52db509e552e1c531eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void agregar(char *linea) { | |
// El que se agregará; reservamos memoria | |
struct nodo *nuevoNodo = malloc(sizeof(struct nodo)); | |
// Le ponemos el dato | |
strcpy(nuevoNodo->linea, linea); | |
// Si es el primer elemento que se agrega... | |
if (superior == NULL) { | |
superior = nuevoNodo; | |
return; | |
} | |
// Si no, buscamos el último elemento y le asignamos el valor al mismo | |
struct nodo *temporal = superior; | |
while (temporal->siguiente != NULL) { | |
temporal = temporal->siguiente; | |
} | |
temporal->siguiente = nuevoNodo; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment