c语言问题,我菜鸟,麻烦给解答下,

#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
这是哪错啦,,,,,

#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;
};
还有你的程序写的格式太不够标准了。。楼上的格式你就可以学习~!
温馨提示:内容为网友见解,仅供参考
第1个回答  2012-04-16
#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;

};
第2个回答  2012-04-16
缺少必要的头文件,指针类型错误。
第3个回答  2012-04-16
菜鸟?
相似回答