我根据要求将代码转换为项目文件。
转换后我遇到了一些重新声明错误:
重新声明时类型不匹配 'n'
n* create_node(int);
声明语法错误
更新代码
运行时出现新错误:
在我包含的一些文件中,新的、第一个和最后一个未定义。
CIRC.H 文件:
#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 文件:
#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;
}
我在这里缺少什么?
最佳答案
我想而不是这个:
struct n *new,
你的意思是
struct node *new,
这里而不是
n* create_node(int);
=> 结构节点 * create_node(int);
关于c - 使用c中的项目文件在双向链表中重新声明错误时类型不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21288540/