-
-
Save parzibyte/7a12cc71ce5cee3559cbdc6574d5f9ab 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 agregarLineaALista(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