I try to create a simple linked list out of a integer vector. Why is this not working? The errors I get are:
'=' : incompatible types - from 'talstrul *' to 'node *'
'=' : cannot convert from 'talstrul*' to talstrul'
This is the .h file:
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
int num;
struct node *next;
} talstrul;
This is the .c file:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "clabb2head.h"
int main()
{ int vek[5] = {1,2,3,4,5};
int langd = sizeof(vek)/sizeof(vek[0]);
printf("%d",langd);
talstrul *temp = malloc(sizeof(talstrul));
talstrul *pek1 = NULL;
int i;
for(i=0; i<langd; i++)
{
pek1 -> num = vek[i];
pek1 -> next = *temp;
*temp = pek1;
}
}
struct nodedefined? 2) Why do you expect to be able to assign*tempof typetalstrultopek1->nextof typestruct node*? There are more, but let's start there.typedef struct {totypedef struct node {. There are other errors, as folks are pointing out.