c - 使用c中的项目文件在双向链表中重新声明错误时类型不匹配

标签 c linked-list queue project doubly-linked-list

我根据要求将代码转换为项目文件。

转换后我遇到了一些重新声明错误:

重新声明时类型不匹配 '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/

相关文章:

c - XCode 5.1 中的 "' portaudio.h ' file not found"错误

algorithm - 合并 K 个排序链表,为什么复杂度是 O(N * K * K),而不是 O(N * K)

c++ - 通过键值的查找函数在 map 中搜索不正确

multithreading - Observable 对不同线程上的队列更改没有反应

c++ - 为什么这个 tbb 程序无法编译?

c - 使用 WinMain() 和 WindowProc() 建立窗口后,在哪里添加实际程序? (C++)

c - 如何将文件中的单词分配给 C 中的二维字符串数组

c - 如何在C中检查以dd-mm-yyyy形式输入的日期的数字?

c - 链表函数调用

python - 过滤器存储队列