Kaskus

Tech

novacammyAvatar border
TS
novacammy
Linked List
Code:
#include<iostream>
#include<ctime>
#include<stdlib.h>
using namespace std;

struct node
{
int data;
struct node *link;
};


int main()
{
srand(time(NULL));
struct node *n;
struct node *p = NULL;
struct node *status = NULL;
n = (struct node*)malloc(sizeof(struct node));
for(int i=0; i<5; i++){
n->data = rand()0+1;
n->link = p;
p = n;

for(int i=0; i<4;i++){
struct node *hapus;
hapus = temp->next;
data = data->next;
temp->link = NULL;
free(temp);
}
cout<< p -> data << " ";
}
return 0;
}

Nah kan disini udah dibnetuk linked list terus rencananya mau dihapus, nah tersu hapusnya gimana ya? soalnya lagi coba tapi nggak ketemu fungsinya.
0
660
2
GuestAvatar border
Komentar yang asik ya
Mari bergabung, dapatkan informasi dan teman baru!
Programmer Forum
Programmer Forum
KASKUS Official
20.2KThread5KAnggota
Urutkan
Terlama
GuestAvatar border
Komentar yang asik ya
Ikuti KASKUS di
© 2026 KASKUS, PT Darta Media Indonesia. All rights reserved.