Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Linked List
//Title of this code //gcc 4.9.2 #include<stdlib.h> #include<stdio.h> #include<string.h> typedef struct cell cell; struct cell{ char*key; cell*next; }; void insert_list(char*key,cell**list){ if(*list==NULL){ *list=(cell*)malloc(sizeof(cell)); (*list)->key=(char*)malloc(sizeof(char)*(strlen(key)+1)); strcpy((*list)->key,key); (*list)->next=NULL; } else if(strcmp(key,(*list)->key)) insert_list(key, &((*list)->next)); } void print(cell*list){ if(list!=NULL){printf("%s\t",list->key);print(list->next);} } int main(){ cell*list=NULL; insert_list("Kevin",&list); insert_list("Parfait",&list); insert_list("Ahmet",&list); print(list); return 0; }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Incometax problem v1.1
Factorial_LOOP
2.3 Comparision with Matrix Multiplication Execution Time
Absolute valu
PROTOTIPO PREGUNTA 1 DE GUÍA 4
PREGUNTA 3 - MODULO 4 TERMINADA
lab5!
Print hostname
Array Struct, Call-By-Reference, Malloc, Free, Init, Destroy ... Example
Square pyramid
Please log in to post a comment.