Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created March 18, 2020 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/e70e895a5a6ec52db509e552e1c531eb to your computer and use it in GitHub Desktop.
Save parzibyte/e70e895a5a6ec52db509e552e1c531eb to your computer and use it in GitHub Desktop.
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