Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
468 views
in Technique[技术] by (71.8m points)

c - C语言程序中的错误和警告(erro and warning in c programe)

I am trying to Make linked list with character[26].

(我正在尝试用字符[26]制作链表。)

which i will be using for String.

(我将用于字符串。)

But there is few error i dont get it please help me thanks.

(但是有一些错误我不明白,请帮助我,谢谢。)

||=== Build: Debug in Symmetric Order (compiler: GNU GCC Compiler) ===|
/home/owais/All Data/Study/Projects/C language projects/Open kittis/Symmetric Order/main.c||In function ‘Create_Set’:|
/home/owais/All Data/Study/Projects/C language projects/Open kittis/Symmetric Order/main.c|23|error: ‘node’ undeclared (first use in this function)|
/home/owais/All Data/Study/Projects/C language projects/Open kittis/Symmetric Order/main.c|23|note: each undeclared identifier is reported only once for each function it appears in|
/home/owais/All Data/Study/Projects/C language projects/Open kittis/Symmetric Order/main.c|21|warning: variable ‘newnode’ set but not used [-Wunused-but-set-variable]|
||=== Build failed: 1 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|


    #include <stdio.h>
#include <stdlib.h>
void Create_Set(int );
struct  node
{
    char name[26];
    struct node *pointer;
};
 struct node Head;
int main()
{

    int n;
    Create_Set(n);
    return 0;
}


void Create_Set(int n)
{
    struct node newnode;

     Head = malloc(sizeof(node));
     newnode.pointer=&Head;

}
  ask by Owais Qureshi translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You are using a node * inside the very definition of node , when the node struct is not defined yet.

(您正在使用一个node *的非常定义中node ,在node结构尚未确定。)

You can use: typedef struct node node;

(您可以使用: typedef struct node node;)

before defining the "real" node struct.

(在定义“真实”节点结构之前。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...