
c语言问题,我菜鸟,麻烦给解答下,
#include<stdio.h>structgood{inta;charb,c;chard[6];struct*link;};structgood*f,*g,*head...
#include<stdio.h>
struct good{int a;char b,c;char d[6];struct*link;};
struct good*f,*g,*head;
void main()
{head=(struct good*)molloc(sizeof(struct good));
head->link=NULL;
tail=head;
node=(struct good*)molloc(sizeof(struct good));
node->a=10;
node->b=r;
node->c=h;
node->d="china";
node->link=NULL;
tail->link=node;
tail=node;
};
: error C2065: 'molloc' : undeclared identifier
: error C2065: 'tail' : undeclared identifier
: error C2440: '=' : cannot convert from 'struct good *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
: error C2065: 'node' : undeclared identifier
: error C2440: '=' : cannot convert from 'struct good *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C : error C2227: left of '->a' must point to class/struct/union
C) : error C2227: left of '->b' must point to class/struct/union
C: : error C2065: 'r' : undeclared identifier
C : error C2227: left of '->c' must point to class/struct/union
C error C2065: 'h' : undeclared identifier
C: : error C2227: left of '->d' must point to class/struct/union
error C2227: left of '->link' must point to class/struct/union
C:\P: error C2227: left of '->link' must point to class/struct/union
这是哪错啦,,,,, 展开
struct good{int a;char b,c;char d[6];struct*link;};
struct good*f,*g,*head;
void main()
{head=(struct good*)molloc(sizeof(struct good));
head->link=NULL;
tail=head;
node=(struct good*)molloc(sizeof(struct good));
node->a=10;
node->b=r;
node->c=h;
node->d="china";
node->link=NULL;
tail->link=node;
tail=node;
};
: error C2065: 'molloc' : undeclared identifier
: error C2065: 'tail' : undeclared identifier
: error C2440: '=' : cannot convert from 'struct good *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
: error C2065: 'node' : undeclared identifier
: error C2440: '=' : cannot convert from 'struct good *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C : error C2227: left of '->a' must point to class/struct/union
C) : error C2227: left of '->b' must point to class/struct/union
C: : error C2065: 'r' : undeclared identifier
C : error C2227: left of '->c' must point to class/struct/union
C error C2065: 'h' : undeclared identifier
C: : error C2227: left of '->d' must point to class/struct/union
error C2227: left of '->link' must point to class/struct/union
C:\P: error C2227: left of '->link' must point to class/struct/union
这是哪错啦,,,,, 展开
4个回答
展开全部
#include<stdio.h>
//缺少头文件
//#include<stdlib.h>(malloc函数)
//#include<string.h>(结构体)
struct good{int a;char b,c;char d[6];struct*link;};
struct good*f,*g,*head;//缺少定义*tail,*node
void main()
{head=(struct good*)molloc(sizeof(struct good));//malloc
head->link=NULL;
tail=head;
node=(struct good*)molloc(sizeof(struct good));
node->a=10;
node->b=r;//字符单引号
node->c=h;//同上
node->d="china";//字符串不能直接用等于
node->link=NULL;
tail->link=node;
tail=node;
};
还有你的程序写的格式太不够标准了。。楼上的格式你就可以学习~!
//缺少头文件
//#include<stdlib.h>(malloc函数)
//#include<string.h>(结构体)
struct good{int a;char b,c;char d[6];struct*link;};
struct good*f,*g,*head;//缺少定义*tail,*node
void main()
{head=(struct good*)molloc(sizeof(struct good));//malloc
head->link=NULL;
tail=head;
node=(struct good*)molloc(sizeof(struct good));
node->a=10;
node->b=r;//字符单引号
node->c=h;//同上
node->d="china";//字符串不能直接用等于
node->link=NULL;
tail->link=node;
tail=node;
};
还有你的程序写的格式太不够标准了。。楼上的格式你就可以学习~!
展开全部
#include<stdio.h>
#include "malloc.h"
#include "string.h"
struct good
{
int a;
char b,c;
char d[6];
struct good *link;
};
struct good*f,*g,*head;
void main()
{
struct good *tail = NULL;
struct good *node = NULL;
head=(struct good*)malloc(sizeof(struct good));
head->link=NULL;
tail=head;
node=(struct good*)malloc(sizeof(struct good));
node->a=10;
node->b='r';
node->c='h';
strcpy(node->d, "china");
node->link=NULL;
tail->link=node;
tail=node;
};
#include "malloc.h"
#include "string.h"
struct good
{
int a;
char b,c;
char d[6];
struct good *link;
};
struct good*f,*g,*head;
void main()
{
struct good *tail = NULL;
struct good *node = NULL;
head=(struct good*)malloc(sizeof(struct good));
head->link=NULL;
tail=head;
node=(struct good*)malloc(sizeof(struct good));
node->a=10;
node->b='r';
node->c='h';
strcpy(node->d, "china");
node->link=NULL;
tail->link=node;
tail=node;
};
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
缺少必要的头文件,指针类型错误。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询