I guess instead of this :
struct n *new,
You meant
struct node *new,
And here instead of
n* create_node(int);
=> struct node * create_node(int);
Question
I converted my code to a project file as per requirement.
after converting it I got some redeclaration errors:
type mismatch in redeclaration of 'n'
declaration syntax error for n* create_node(int);
UPDATED CODE
new error upon running:
new, first and last are undefined in some of my included files.
CIRC.H file:
#ifndef CIRC_H
#define CIRC_H
struct node{
int val;
struct node *next;
struct node *prev;
};
typedef struct node n;
struct node * create_node(int);
int add_node();
int insert_at_first();
int insert_at_end();
int insert_at_position();
int delete_node_position();
int sort_list();
int update();
int search();
int display_from_beg();
int display_in_rev();
#endif
CIRC.C File:
#include "CIRC.H"
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
struct node *new, *ptr, *prev;
struct node *first = NULL, *last = NULL;
int number = 0;
void main(){
int ch;
clrscr();
while (1){
//textt
}
}
struct node * create_node(int info){
number++;
new = (struct node *)malloc(sizeof(n));
new->val = info;
new->next = NULL;
new->prev = NULL;
return new;
}
What am I missing here?
Solution
I guess instead of this :
struct n *new,
You meant
struct node *new,
And here instead of
n* create_node(int);
=> struct node * create_node(int);