Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PRACTICA LISTA
#include <stdio.h> #include <stdlib.h> // Definir estructura que almacenará los nodos de la lista typedef struct { char date[51]; struct nodo *nextPtr; }node; node *input(node *, char *); void output(node * ); int main(void) { node *list = NULL; list = input(list, "MANUEL"); output(list); list = input(list, "VALESKA"); output(list); list = input(list, "CARLOS"); output(list); return 0; } // Implementation of functions node *input(node *list, char *str) { node *listAux; node *ptrList; ptrList = malloc(sizeof(node)); if ( ptrList == NULL) { printf( "%s not inserted. No memory available.\n", str ); exit(EXIT_FAILURE); } strcpy(ptrList -> date, str); //ptrList -> date = value; ptrList -> nextPtr = NULL; if ( list == NULL) list = ptrList; else { listAux = list; while ( (listAux -> nextPtr) != NULL ) { listAux = listAux->nextPtr; } listAux -> nextPtr = ptrList; } return list; } void output(node *list) { while ( list != NULL ) { printf("%s --> ", list -> date); list = list-> nextPtr; } printf("NULL\n"); }
run
|
edit
|
history
|
help
0
A_141124_arrayMaxMin02
Memory leak
challoc
hello
segundo avance de la lista enlazada
Cuenta codigos
printint a struct
Program 1 - 2D array and memory pointers
Prgm
child process