user-0 提问: 栈问题

回复:
user: user-1
content: （*s)->next;错误的地方看一看看报错自己修改修改在

user: user-2
content: mg=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/2.gif][/img]  哦哦 不小心 移了 一个 i

user: user-2
content: *S->top++ = e; 运算符 suffix ++ 优先级最低吧  这样 编译期会有错误吧。。。 结构对象被打开了 不能++了吧。。。 我这里是不能加了啊。。。  我对上边 大哥 给出的 C++优先级表 的 描述语 有些不太理解 //| ++               | Postfix increment                       | None    后缀自增 优先级老高了 但我这里 很低啊。。  g++ t3.cpp -o t3pp out : 4  //  #include<stdio.h> struct aa     {         int aa;         int bb;     };      int main()     {         int a = 2;         int b = 2 * a++;         printf("%d\n", b);         return 0;                 //struct aa aa1 = {};        //aa1 + 1 = 0;        //* (char*)(&aa1 +1) = 0;     }  另外 除了楼主说的 那个表达式 优先级有些错误外 其他代码的逻辑 没有细看mg=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/2.gif][/img]  最后 加油吧！

user: user-3
content: 引用 楼主 helloworld1014 的回复:/* **栈的实现 */ #include "datastruct.h"  /* **栈的存储结构 */ #define STACK_INIT_SIZE 100				//存储空间初始分配量 #define STACKINCREMENT 10				//存储空间 分配增量 typedef struct{ 	ElemType *base;						//栈底指针 	ElemType *top;						//栈顶指针 	int stacksize;						//当前分配存储空间 }SqStack;  /* **构造一个空栈 */ Status InitStack(SqStack* S) { 	S->base = (ElemType*)malloc(STACK_INIT_SIZE * sizeof(ElemType)); 	if(S->base == NULL) 		return ERROR; 	else{ 		S->base = S->top;					//空栈 		S->stacksize = STACK_INIT_SIZE; 		return OK; 	} }  /* **获取站定元素，但不删除该元素 */ Status GetTop(SqStack* S, ElemType *e) { 	if(S->base == S->top) 		return ERROR; 	*e = *(S->top-1); 	return OK; }  /* **向栈插入新的元素 */ Status Push(SqStack* S, ElemType e) { 	if(S->top - S->base >= S->stacksize){              //判断栈是否满 		S->base = (ElemType*)realloc(S->base, (STACKINCREMENT+STACKINCREMENT) * sizeof(ElemType)); 		if(S->base == NULL) 			exit(OVERFLOW); 		else{ 			S->top = S->base + S->stacksize; 			S->stacksize += STACKINCREMENT; 		} 	} 	*S->top++ = e;               //程序跑到这就报错，不知道什么原因 	return OK; }  int main(int argc, char* argv[]) { 	SqStack S; 	int i; 	InitStack(&S); 	for (i=0;i<10;i++) 	{ 		Push(&S,i); 	} 	system("pasue"); 	return 0; }  *S->top++ = e;               //程序跑到这就报错，不知道什么原因 大家看看啥原因？ 看到你源码的第26行，我就不往下看了，先解决这个问题吧。

user: user-4
content: 整个写法和思路都有问题，指针不知所向，参考http://blog.csdn.net/hopeyouknow/article/details/6725049

user: user-5
content: //C++ Operators //  Operators specify an evaluation to be performed on one of the following: //    One operand (unary operator) //    Two operands (binary operator) //    Three operands (ternary operator) //  The C++ language includes all C operators and adds several new operators. //  Table 1.1 lists the operators available in Microsoft C++. //  Operators follow a strict precedence which defines the evaluation order of //expressions containing these operators.  Operators associate with either the //expression on their left or the expression on their right;    this is called //“associativity.” Operators in the same group have equal precedence and are //evaluated left to right in an expression unless explicitly forced by a pair of //parentheses, ( ). //  Table 1.1 shows the precedence and associativity of C++ operators //  (from highest to lowest precedence). // //Table 1.1   C++ Operator Precedence and Associativity // The highest precedence level is at the top of the table. //+------------------+-----------------------------------------+---------------+ //| Operator         | Name or Meaning                         | Associativity | //+------------------+-----------------------------------------+---------------+ //| ::               | Scope resolution                        | None          | //| ::               | Global                                  | None          | //| [ ]              | Array subscript                         | Left to right | //| ( )              | Function call                           | Left to right | //| ( )              | Conversion                              | None          | //| .                | Member selection (object)               | Left to right | //| ->               | Member selection (pointer)              | Left to right | //| ++               | Postfix increment                       | None          | //| --               | Postfix decrement                       | None          | //| new              | Allocate object                         | None          | //| delete           | Deallocate object                       | None          | //| delete[ ]        | Deallocate object                       | None          | //| ++               | Prefix increment                        | None          | //| --               | Prefix decrement                        | None          | //| *                | Dereference                             | None          | //| &                | Address-of                              | None          | //| +                | Unary plus                              | None          | //| -                | Arithmetic negation (unary)             | None          | //| !                | Logical NOT                             | None          | //| ~                | Bitwise complement                      | None          | //| sizeof           | Size of object                          | None          | //| sizeof ( )       | Size of type                            | None          | //| typeid( )        | type name                               | None          | //| (type)           | Type cast (conversion)                  | Right to left | //| const_cast       | Type cast (conversion)                  | None          | //| dynamic_cast     | Type cast (conversion)                  | None          | //| reinterpret_cast | Type cast (conversion)                  | None          | //| static_cast      | Type cast (conversion)                  | None          | //| .*               | Apply pointer to class member (objects) | Left to right | //| ->*              | Dereference pointer to class member     | Left to right | //| *                | Multiplication                          | Left to right | //| /                | Division                                | Left to right | //| %                | Remainder (modulus)                     | Left to right | //| +                | Addition                                | Left to right | //| -                | Subtraction                             | Left to right | //| <<               | Left shift                              | Left to right | //| >>               | Right shift                             | Left to right | //| <                | Less than                               | Left to right | //| >                | Greater than                            | Left to right | //| <=               | Less than or equal to                   | Left to right | //| >=               | Greater than or equal to                | Left to right | //| ==               | Equality                                | Left to right | //| !=               | Inequality                              | Left to right | //| &                | Bitwise AND                             | Left to right | //| ^                | Bitwise exclusive OR                    | Left to right | //| |                | Bitwise OR                              | Left to right | //| &&               | Logical AND                             | Left to right | //| ||               | Logical OR                              | Left to right | //| e1?e2:e3         | Conditional                             | Right to left | //| =                | Assignment                              | Right to left | //| *=               | Multiplication assignment               | Right to left | //| /=               | Division assignment                     | Right to left | //| %=               | Modulus assignment                      | Right to left | //| +=               | Addition assignment                     | Right to left | //| -=               | Subtraction assignment                  | Right to left | //| <<=              | Left-shift assignment                   | Right to left | //| >>=              | Right-shift assignment                  | Right to left | //| &=               | Bitwise AND assignment                  | Right to left | //| |=               | Bitwise inclusive OR assignment         | Right to left | //| ^=               | Bitwise exclusive OR assignment         | Right to left | //| ,                | Comma                                   | Left to right | //+------------------+-----------------------------------------+---------------+