I am using the following code but its showing error : expected constructor, destructor or type conversion before * token. Its showing the error in function prototype and the function declaration lines.
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
node *insert(node *head); // the compiler is showing error here
main()
{
int dat;
char x,ch;
struct node_type
{
int data;
node_type *next;
};
typedef struct node_type node;
// node *head;
node *temp;
// head= NULL;
temp=NULL;
printf("do u wanna enter a new node? \n");
scanf("%c", &x);
if (x=='y' or x=='Y')
{
temp=(node *)malloc(sizeof(node));
printf("enter the data: \n");
scanf("%d ", &dat);
temp->data= dat;
temp->next = NULL;
}
printf("do u want to insert another element?\n");
scanf("%c ", &ch);
if( ch=='y' or ch=='Y')
{
insert(*temp);
}
getch();
}
node *insert(node *temp)
{
int dat;
char ch;
node *new;
new=(node *)malloc(sizeof(node));
printf("enter the data: ");
scanf(" %d ", &dat);
new->data=dat;
new->next=temp;
temp=new;
printf("do u want to insert another element?\n");
scanf("%c ", &ch);
if (ch == 'y' or ch == 'Y')
{
insert(*temp);
}
else
return temp;
}
what is the error and how do i rectify it?
int main(void)at least, please!