一个关于链栈的题目(急啊)

来源:百度知道 编辑:UC知道 时间:2024/09/23 08:23:39
#include "stdio.h"
#include "stdlib.h"
#define max 10
typedef struct sequeue{
char elem[max];
int top;
}sequeue;
void edit(){
sequeue *s;
s->top=0;
scanf("%c",&s->elem);
while(s->elem!="*")
{
if(s->elem=="#")
s->top--;
else if(s->elem=="@")
s->top=0;
else {
s->elem[s->top]=s->elem;
s->top++;
}
scanf("%c",&s->elem);
}
while(s->top!=0){
printf("%c",s->elem[s->top]);
s->top--;
}
}
void main(){
edit();
}

老提示Compiling...
Cpp1.cpp
D:\My Documents\my program\Cpp1.cpp(20) : error C2440: '=' : cannot convert from 'char [10]' to 'char'
This conversion requires a reinterpret_cast, a C-style cast or function-style c

s->elem 为一地址~~不能而你的意思是将其指向的元素赋值
#include "stdio.h"
#include "stdlib.h"
#define max 10
typedef struct sequeue{
char elem[max];
int top;
}sequeue;
void edit(){
sequeue *s;

s->top=0;
scanf("%c",&s->elem);
while(s->elem!="*")
{
if(s->elem=="#")
s->top--;
else if(s->elem=="@")
s->top=0;
else {
s->elem[s->top]=*s->elem;
s->top++;
}
scanf("%c",&s->elem);
}
while(s->top!=0){
printf("%c",s->elem[s->top]);
s->top--;
}
}
void main(){
edit();
}

字符串比较 应该用 strcmp
字符串复制 应该用 strcpy