#include <stdio.h>
#include <stdlib.h>
#define ROZ 100
struct lista
{
char *imie ;
char *nazwisko;
long int data;
struct wsk * next;
};
int add (struct lista** head)
{
struct lista *wsk;
wsk=(struct lista*)malloc(sizeof(struct lista));
long int data;
wsk->imie=(char*)malloc(ROZ);
if(wsk-> imie==NULL)
return -1;
wsk->nazwisko=(char*)malloc(ROZ);
if(wsk->nazwisko==NULL)
return -2;
printf("podaj imie");
fgets(wsk->imie,ROZ,stdin);
printf("podaj nazwisko");
fgets(wsk->nazwisko, ROZ, stdin);
printf("podaj date urodzenia");
scanf("%ld",&data);
wsk->data=data;
wsk->next=(*head);
(*head)=wsk;
}
main()
{
struct lista *head, *wsk;
int a, spr;
while(a!=4)
{
printf("Aby wypisac liste wpisz 1, aby dodac wiersz wpisz 2, aby usunac wiersz wpisz 3, aby zakonczyc prace programu wpisz 4");
scanf("%d",&a);
if(a==2)
{
spr=add(&head);
{
if(spr<0)
printf("blad");
}
}
}
}
I don't know how am I suppose to move the head of the list(29 line), program doesn't compile there.
struct lista *head;head is not initialised.int a, spr; while(a!=4){...}- Here,aisn't initialized.struct wskwas (which is not what astruct listais) at least one of your errors would be more obvious.struct wsktype.