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
fork
Cuenta codigos
printf
My first program
sizeof human
lab 11 v0.7
A141212_OrdenarArrayPorFunciones
to upper case string
Programação em C, testes
My C Code