stacks,error:no response on stdout.

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <stack>
#include <string>
using namespace std;


int main() {
stack<char> F;
stack<char> F1;
stack<char> F2;
int a;
cin>>a;
int b[a];
char word;
for(int i = 0;i<a;i++){
cin>>b[i];
}
while(cin>>word){
F.push(word);
}
while(cin>>word){
F1.push(word);
}
while(cin>>word){
F2.push(word);
}

for(int i=a-1;i>-1;i--){
if(b[i]==2){
char l1=F2.top();
F.push(l1);
F2.pop();
}
else {
char l=F1.top();
F.push(l);
F1.pop();

}
}
while(!F.empty()){
char k=F.top();
cout<<k;
F.pop();
}
while(!F1.empty()){
cout<<F1.top();
F1.pop();
}
while(!F2.empty()){
cout<<F2.top();
F2.pop();
}


return 0;
}
Last edited on
error:
GDB trace:
Reading symbols from solution...done.
[New LWP 13147]
Core was generated by `solution'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 main () at solution.cc:39
39 char l=F1.top();
#0 main () at solution.cc:39
Hi,
Please always use code tags www.cplusplus.com/articles/z13hAqkS/

The following is illegal C++ (variable sized array) try using std::vector instead
1
2
3
int a;
cin>>a;
int b[a];


What are you trying to achieve with your code? It looked like a lot of code to reverse a string.

Please don't start a new topic on the same subject, it ultimately a time waster for those who reply.
sorry about new topics
didnt knew where to submit
Cause Im new
Im just solving an exercise and there is no response on stdout.
My code just take some inputs in stacks and in array . Then doing sth (Algorithm). And then just output the stacks
didnt knew where to submit


Beginners forum is fine. Best to quit with this topic and carry on with the other one. I deleted the third topic you had. Write a reply saying you are quitting this topic, and post a link to the other one.

Im just solving an exercise and there is no response on stdout.


What is the exercise you are trying to solve? You will get better answers if you write better questions. We aren't mind readers, you know.

Did you implement my earlier suggestion?
Did you implement my earlier suggestion?

No,i must solve it with stacks.
What is the exercise you are trying to solve?

Answer in the other topic.
Last edited on
Im quiting this topic ,there is a similar in Begineers forum:


http://www.cplusplus.com/forum/beginner/227615/
Topic archived. No new replies allowed.