error C2065 未声明的标识符。 已经引入头文件为什么还是未声明?

qq_34378352 2016-10-11 11:16:57
#include "LinkedStack.h"

#define status int
#define pane_height 51
#define pane_width 51

int maze[pane_width][pane_height]={0};

void AddwallList(Node *head, int x, int y){
if(x>1){
if(maze[x-2,y]!=0){
Push(head, x-1, y);
}
}
if(x<pane_width-2){
if(maze[x+2,y]!=0){
Push(head, x+1, y);
}
}
if(y>1){
if(maze[x,y-2]!=0){
Push(head, x, y-1);
}
}
if(y<pane_width-2){
if(maze[x,y+2]!=0){
Push(head, x, y+1);
}
}
}

status theMaze(){
int a,b,c;//use for init

//init the maze
for (a=0,b=0,c=pane_width-1;a<pane_height;){
maze[a][b]=2;
maze[a][c]=2;
a++;
}
for (a=0,b=0,c=pane_height-1;b<pane_width;){
maze[a][b]=2;
maze[c][b]=2;
b++;
}

//all is wall
for (a=1;a<pane_height-1;){
for(b=2;b<pane_width-1;){
maze[a][b]=1;
b+=1;
}
a+=1;
for(b=1;b<pane_width-1;){
maze[a][b]=1;
b+=1;
}
a+=1;
}

//init the wallList

Node *head; (错误 6 error C2065: “head”: 未声明的标识符 )
head = creat(); (错误 2 error C2275: “Node”: 将此类型用作表达式非法)

//pick a cell as a part of amze, adding walls of the cell to wallList
maze[1][1]=0;
AddwallList(head, 1, 1);

//printf the maze
for (a=0;a<pane_height;){
for(b=0;b<pane_width;){
printf("%d",maze[a][b]);
b++;
}
a++;
printf("\n");
}
return 1;
}

int main(){
theMaze();
system("pause");
}

用vs2010 和C语言写的。有点不明白为什么已经引用头文件还是不能定义
...全文
1749 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Sniper_Pan 2016-10-12
  • 打赏
  • 举报
回复
VS2013测试通过,建议完全重编下试试
qq_34378352 2016-10-12
  • 打赏
  • 举报
回复
谢谢指正!Bug我都修改了。但是还是老情况 Node *head; head = creat(); 会提示head未声明的标识符,Node此类型用作表达式非法。 是VS2010的问题吗? 修正以后的代码: #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct vector{ int x; int y; }vec; typedef struct node{ vec a; struct node *next; }Node; Node *creat(); void DestoryStack(Node *head); int StackEmpty(Node *head); int StackLenth(Node *head); int GetTop(Node *head, vec *b); void Push(Node *head, int a, int b); void Pop(Node *head); Node *creat(){ Node *head = NULL; head = (Node *)malloc(sizeof(Node)); if (head == NULL){ printf("fail to creat"); return NULL; } head -> next = NULL; return head; } void DestoryStack(Node *head){ if (head){ Node *tail, *pnew = NULL; if (head ->next) tail = head ->next; free(head); while (tail ->next){ pnew = tail ->next; free(tail); } free(pnew); } } int StackEmpty(Node *head){ if(head->next){ return 1; } return 0; } int StackLenth(Node *head){ int num; Node *tail = NULL; if(head)num=1; else return 0; tail = head; if(tail->next){ tail = tail->next; num++; } return num; } int GetTop(Node *head, vec *b){ Node *tail = NULL; tail = head; if(!StackEmpty(head)){ if(head->next){ tail = tail->next; } b= &tail->a; return 1; } return 0; } void Push(Node *head, int a, int b){ Node *tail, *pnew = NULL; tail = head; if(!StackEmpty(head)){ if(head->next){ tail = tail->next; } tail->next=(Node *)malloc(sizeof(Node)); pnew = tail->next; pnew->next = NULL; pnew->a.x = a; pnew->a.y = b; } } void Pop(Node *head){ Node *tail, *last = NULL; tail = head; last = head; if(!StackEmpty(head)){ if(head->next){ tail = last; last = last->next; } free(last); tail->next =NULL; } }
paschen 2016-10-11
  • 打赏
  • 举报
回复
if (head = NULL){ 改成 if (head == NULL){ GetTop 不是所有路径都有返回 extern Node *creat(){ 写成 Node *creat(){ 吧
dustpg 2016-10-11
  • 打赏
  • 举报
回复
我这没问题, 不过bug太多了, 严重性 代码 说明 项目 文件 行 禁止显示状态 警告 C4709 逗号运算符在数组索引表达式内 DDT1 c:\users\administrator\documents\visual studio 15\projects\project1\ddt1\main.c 11 警告 C4709 逗号运算符在数组索引表达式内 DDT1 c:\users\administrator\documents\visual studio 15\projects\project1\ddt1\main.c 16 警告 C4709 逗号运算符在数组索引表达式内 DDT1 c:\users\administrator\documents\visual studio 15\projects\project1\ddt1\main.c 21 警告 C4709 逗号运算符在数组索引表达式内 DDT1 c:\users\administrator\documents\visual studio 15\projects\project1\ddt1\main.c 26 警告 C4706 条件表达式内的赋值 DDT1 c:\users\administrator\documents\visual studio 15\projects\project1\ddt1\linkedstack.h 26 错误 C4703 使用了可能未初始化的本地指针变量“tail” DDT1 c:\users\administrator\documents\visual studio 15\projects\project1\ddt1\linkedstack.h 40 错误 C4703 使用了可能未初始化的本地指针变量“pnew” DDT1 c:\users\administrator\documents\visual studio 15\projects\project1\ddt1\linkedstack.h 44 警告 C4701 使用了可能未初始化的局部变量“tail” DDT1 c:\users\administrator\documents\visual studio 15\projects\project1\ddt1\linkedstack.h 40 警告 C4701 使用了可能未初始化的局部变量“pnew” DDT1 c:\users\administrator\documents\visual studio 15\projects\project1\ddt1\linkedstack.h 44 警告 C4715 “GetTop”: 不是所有的控件路径都返回值 DDT1 c:\users\administrator\documents\visual studio 15\projects\project1\ddt1\linkedstack.h 77
qq_34378352 2016-10-11
  • 打赏
  • 举报
回复
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct vector{ int x; int y; }vec; typedef struct node{ vec a; struct node *next; }Node; extern Node *creat(); void DestoryStack(Node *head); int StackEmpty(Node *head); int StackLenth(Node *head); struct vector GetTop(Node *head); void Push(Node *head, int a, int b); void Pop(Node *head); extern Node *creat(){ Node *head; head = (Node *)malloc(sizeof(Node)); if (head = NULL){ printf("fail to creat"); return NULL; } head -> next = NULL; return head; } void DestoryStack(Node *head){ if (head){ Node *tail, *pnew; if (head ->next) tail = head ->next; free(head); while (tail ->next){ pnew = tail ->next; free(tail); } free(pnew); } } int StackEmpty(Node *head){ if(head->next){ return 1; } return 0; } int StackLenth(Node *head){ int num; Node *tail; if(head)num=1; else return 0; tail = head; if(tail->next){ tail = tail->next; num++; } return num; } struct vector GetTop(Node *head){ Node *tail; tail = head; if(!StackEmpty(head)){ if(head->next){ tail = tail->next; } return tail->a; } } void Push(Node *head, int a, int b){ Node *tail, *pnew; tail = head; if(!StackEmpty(head)){ if(head->next){ tail = tail->next; } tail->next=(Node *)malloc(sizeof(Node)); pnew = tail->next; pnew->next = NULL; pnew->a.x = a; pnew->a.y = b; } } void Pop(Node *head){ Node *tail, *last; tail = head; last = head; if(!StackEmpty(head)){ if(head->next){ tail = last; last = last->next; } free(last); tail->next =NULL; } } 这是头文件。麻烦帮忙看看!!
2011年12月8日,ISO正式发布了新的C语言的新标准C11,之前被称为C1X,官方名称为ISO/IEC 9899:2011。 新的标准提高了对C++的兼容性,并增加了一些新的特性。这些新特性包括: 对齐处理(Alignment)的标准化(包括_Alignas标志符,alignof运算符, aligned_alloc函数以及头文件。 _Noreturn 函数标记,类似于 gcc 的 __attribute__((noreturn))。 _Generic 关键字。 多线程(Multithreading)支持,包括:_Thread_local存储类型标识符头文件,里面包含了线程的创建和管理函数。 增强的Unicode的支持。基于C Unicode技术报告ISO/IEC TR 19769:2004,增强了对Unicode的支持。包括为UTF-16/UTF-32编码增加了char16_t和char32_t数据类型,提供了包含unicode字符串转换函数的头文件. 删除了 gets() 函数,使用一个新的更安全的函数gets_s()替代。 增加了边界检查函数接口,定义了新的安全的函数,例如 fopen_s(),strcat_s() 等等。 增加了更多浮点处理宏。 匿名结构体/联合体支持。这个在gcc早已存在,C11将其引入标准。 静态断言(Static assertions),_Static_assert(),在解释 #if 和 #error 之后被处理。 新的 fopen() 模式,(“…x”)。类似 POSIX 中的 O_CREAT|O_EXCL,在文件锁中比较常用。 新增 quick_exit() 函数作为第三种终止程序的方式。当 exit()失败时可以做最少的清理工作。 _Atomic类型修饰符和头文件

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧