某项目中使用了stl的栈,可是调试一直有问题,结果精简到这里,请问它的运行结果为什么那么奇怪,我发现那个char*换成char,以及op[100]换成op就正常了,这是为什么呢
输入
1 2
输出
2 2
是哪里出问题了吗?
#include<iostream>
#include<stack>
using namespace std;
int main()
{
char op[100];
stack<char*> a;
for (int i=0;i<2;i++)
{
cin>>op;
a.push(op);
}
while(!a.empty())
{
cout<<a.top()<<endl;
a.pop();
}
return 0;
}