1. ## I need help with my code [linked list]

Hello everyone,
this program is supposed to be quite simple. I tried to debug it for some time but couldn't realize what seems to be the problem. I'll be greatful for your help!

The functioned is meant to get an array and its size, and returns the address of a linked list only with the elements that appear once. example:
for this array:
 57 9 88 74 57 88 74 57 6 57

the output will be:

---->6---->9

the code:
Code:
```#include <stdio.h>
#include <stdlib.h>
#define N 40
typedef struct NODE node;
typedef struct NODE{
int data;
node* next;
};
node* list(int ar[N], int size);
void main(){
int arr[] = { 57, 6, 57, 74, 88, 57, 74, 88, 9, 57 };
node* new_list = list(arr[10], 10);
node* tempi = new_list;
while (tempi->next != NULL){
printf("%d ->", tempi->data);
}
if (tempi->next == NULL) printf("%d", tempi->data);
}

node* list(int ar[N], int size){
int i;

for (i = 1; i < size; i++){
while((temp->data != ar[i]) && (temp->next != NULL)){
temp = temp->next;
}
if ((temp->next == NULL) && (temp->data != ar[i])){
temp->next = (node*)malloc(sizeof(node));
temp = temp->next;
temp->data = ar[i];
temp->next = NULL;
}
}

}```

2. There are three things that need fixing:
Code:
```typedef struct NODE{
int data;
node* next;
};```
Remove the typedef keyword here.

Code:
`node* new_list = list(arr[10], 10);`
Remove the index on arr. You're passing an array, not an element in the array.

Code:
```while (tempi->next != NULL){
printf("%d ->", tempi->data);
}```
The loop will execute infinitely because tempi is never changed. This fixes it:
Code:
```while (tempi->next != NULL)
{
printf("%d ->", tempi->data);
tempi = tempi->next;
}```
Those are the only changes I made for the code as posted to function. And I'll let someone else .......... about void main and casting malloc.

3. about your second change - if I remove the number inside the brackets it says "expected an expression".

didn't notice the third one... thanks
it still encounters something endless and won't output anything though :/

4. Remove the brackets too: they are part of the index notation, after all.

5. if I remove the number inside the brackets it says "expected an expression".
No, remove the brackets too:
Code:
`node* new_list = list(arr, 10);`
it still encounters something endless and won't output anything though :/
Post your new code after the above fix.

6. It's working!
It didn't output the result it prints once all the numbers, rather the numbers that appears once.. but that's something I need solve

Thank you all very much!!