The error is that it prints out the memory instead the values of each node. I tried all combinations of pointers and different printing styles but they all show up as memory leaks.
Here is my code:
#include <stdio.h>//headers
#include <stdlib.h>
struct node{
int val;
struct node *next;
};//linked list
struct node *curr = NULL;//list pointers
struct node *prev = NULL;
struct node *head = NULL;
int main(){
int i;
struct node *curr = (struct node*) malloc(sizeof(struct node));
head=curr;//sets head node
for (i=1;i<=5;i++){
curr->val=i;//sets data
struct node *prev = (struct node*) malloc(sizeof(struct node));
curr->next=prev;
curr=prev;//links to previous node
printf("%d\n", *curr);//prints out data
}
return 0;
}