#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void* zapisz(int vliczba, char vnapis[50]);
void wyswietl(struct struktura *wp);
int liczba;
char napis[50];
struct struktura *wsk = NULL;
struct struktura
{
int sliczba;
char snapis[50];
};
void* zapisz(int vliczba, char vnapis[50])
{
struct struktura *p = (struct struktura*)malloc(sizeof(struct struktura));
p->sliczba = vliczba;
strcpy(p->snapis,vnapis);
return p;
};
void wyswietl(struct struktura *wp)
{
printf("Liczba: %d\n", (*wp).sliczba);
printf("Napis: %s\n", (*wp).snapis);
free(wp);
wp = NULL;
};
//===============================
int main()
{
system("clear"); // system("cls/clear"); windows/ubuntu
printf("Podaj liczbe: ");
scanf("%d",&liczba);
printf("Podaj napis: ");
scanf("%s",napis);
wsk = zapisz(liczba,napis);
wyswietl(wsk);
return(0);
}
Tak wygląda mój program. Nie mogę dojść co jest źle dlatego zwracam się do was o pomoc. Problem jaki wywala kompilator:
[Error] invalid conversion from 'void*' to 'struktura*' [-fpermissive]
devc++
Proszę o pomoc