Untitled
unknown
plain_text
4 years ago
859 B
11
Indexable
#include <stdio.h>
#include <stdlib.h>
struct node {
int data;
struct node *next;
} ;
void printList(struct node *head){
struct node *tmp = head;
while (tmp!=NULL)
{
printf("%d\n",tmp->data);
tmp = tmp->next;
}
}
void arayaEkle(){
}
void sondanSil(struct node *firstNode){
struct node *gecici = firstNode;
while (gecici->next->next!=NULL)
{
gecici=gecici->next;
}
free(gecici->next);
gecici->next=NULL;
}
int main()
{
struct node *d1;
struct node *d2;
struct node *d3;
d1=(struct node*)malloc(sizeof(struct node));
d2=(struct node*)malloc(sizeof(struct node));
d3=(struct node*)malloc(sizeof(struct node));
d1->data=1,d2->data=2,d3->data=3;
d1 ->next=d2,d2 ->next=d3 ,d3-> next=NULL;
printList(d1);
sondanSil(d1);
return 0;
}
Editor is loading...