I am reviewing material i have covered in c and i wrote up some notes and i am getting an error, i was hoping if someone could help me with this
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node{
int data;
struct node *next;
};
void addtobegining(int);
void traverse();
struct node *head;
int main()
{
head = (struct node*)malloc(sizeof(struct node));
addtobegining(3);
addtobegining(2);
addtobegining(1);
traverse();
}
void addtobegining(int i)
{
struct node*p;
p = malloc(sizeof(struct node));
p ->next = i;
head = p;
}
void traverse()
{
struct node *p;
p = head;
while(p);
{
printf("%d\n",p ->data);
p=p ->next;
}
}
i am getting an error at function addtobegining
warning assignment makes pointer to interger without a cast
thanks in advance