Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- typedef struct list{
- char nome[81];
- char tel[15];
- char cel[15];
- char add[101];
- list* next;
- }Lista;
- Lista* new_list(){
- return NULL;
- }
- Lista* lst_insere (Lista* lst, char* nome,char* tel, char* cel, char* add){
- Lista* new_l = (Lista*)malloc(sizeof(Lista));
- strcpy(new_l->nome,nome);
- strcpy(new_l->tel,tel);
- strcpy(new_l->cel,cel);
- strcpy(new_l->add,add);
- new_l->next = lst;
- return new_l;
- }
- void lst_print(Lista* lst){
- Lista* aux;
- for(aux = lst; aux!=NULL; aux = aux->next){
- printf("Conteudo %s\n", aux->nome);
- }
- }
- int lst_void (Lista* lst){
- return (lst == NULL);
- }
- Lista* lst_search (Lista* lst, char* termo){
- Lista* search;
- for(search = lst; search!=NULL; search = search->next){
- if(strcmp(termo,lst->nome) == 0){
- return search;
- }
- }
- return NULL;
- }
- Lista* lst_remove (Lista* lst, char* value){
- Lista* anterior = NULL;
- Lista* aux = lst;
- while(aux != NULL && strcmp(value,lst->nome) != 0){
- anterior = aux;
- aux = aux->next;
- }
- if(aux == NULL){
- return lst;
- }
- if(anterior == NULL){
- lst = aux->next;
- }
- else{
- anterior->next = aux->next;
- }
- free(aux);
- return lst;
- }
- Lista* lst_copy(Lista* lst){
- Lista* p;
- Lista* nl;
- nl = p;
- return nl;
- }
- void lst_destroy(Lista* lst){
- Lista* aux = lst;
- while(aux != NULL){
- Lista* t = aux->next;
- free(aux);
- aux = t;
- }
- }
- int main(void){
- Lista* list;
- Lista* copia;
- char nome[81],tel[15],cel[15],add[101];
- copia = new_list();
- list = new_list();
- for(int i=0; i<3; i++){
- fgets(nome,81,stdin);
- list = lst_insere(list,nome,"15","155","aeho");
- }
- copia = lst_copy(list);
- lst_print(copia);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement