标题: VC [C4700] local variable 's' used without having been initialized [打印本页] 作者: jihuaneva 时间: 2006-12-29 14:36 标题: VC [C4700] local variable 's' used without having been initialized 原始标题:VC [C4700] 错误,无法解决
#include<stdio.h>
#define MAX 100
#define NULL 0
struct stack /*定义栈存储结构*/
{int data_stack[MAX];
int top;
};
typedef struct stack STACK;
STACK *createstack(void) /*创建一个栈*/
{STACK *s;
int len,i,num;
printf("\n\n请输入单链表的长度:");
scanf("%d",&len);
s->top=len;
printf("\n↓请输入顺序表的数据↓\n");
for(i=1;i<=s->top;i++)
{printf("输入第%d个数据:",i);
scanf("%d",&num);
s->data_stack[i]=num;
}
return(s);
}
void outstack(STACK *s) /*输出一个栈*/
{
int i;
if(s->top==0)
printf("\n该栈为空,没有数据!\n");
printf("\n栈的数据:");
for(i=1;i<=s->top;i++)
printf("%d ",s->data_stack[i]);
printf("\n");
}
void push(STACK *s,int x) /*将x压入栈s中*/
{if(s->top==MAX-1)
printf("该栈已满,无法插入数据");
else
s->data_stack[++s->top]=x;
}
void pop(STACK *s) /*出栈操作*/
{ int x;
if(s->top==NULL)
printf("\n该栈为空,没有数据!\n");
else
x=s->data_stack[s->top--];
printf("出栈的数据为:");
printf("%d\n",x);
}
void main() /*实验五:栈的基本运算*/
{STACK *s1;
int num;
s1=createstack();
outstack(s1);
printf("\n输入进栈数据:");
scanf("%d",&num);
push(s1,num);
outstack(s1);
pop(s1);
outstack(s1);}
复制代码
不知道为什么 提示warning C4700: local variable 's' used without having been initialized
我已经定义了s可是为什么还是运行失败,不过在TC环境下可以成功运行,但是在VC下面就有这个警告
不知道为什么,还请哪一位高人。帮忙看看,小弟在此谢过
非常感谢你``
我一定以后加倍努力学习VC
谢谢了!作者: 040240216 时间: 2006-12-29 15:02
local variable 's' used without having been initialized作者: langue 时间: 2006-12-29 16:00
local variable 's' used without having been initialized