Warnings when creating a singly linked list with arrays
#include <stdio.h> typedef struct { int data; struct node *next; }node; void print(node *head) { node *tmp = head; while (tmp) { printf ("%d ", tmp->data); tmp = tmp->next; } } int main() { node arr[5] = { {1, &arr[1]}, {2, &arr[2]}, {3, &arr[3]}, {4, &arr[4]}, {5, NULL} }; print(arr); return 0; } Why do i get these warnings while compiling with gcc -Wall ? (even without -Wall, gcc produces the same warnings) list.c: In function ‘print’: list.c:15:7: warning: assignment from incompatible pointer type [enabled by default] list.c: In function ‘main’: list.c:22:18: warning: initialization from