fork download
  1. #include <string>
  2. #include <iostream>
  3. const bool REVERSE=1;
  4. const bool NORMAL=0;
  5.  
  6. Fifo* init(){
  7. Fifo *f=NULL;
  8. return f;
  9. }
  10.  
  11. void put(Fifo * &f,std::string value){
  12. Fifo *add=new Fifo;
  13. if(add==NULL){
  14. std::cout<<"Nie udało się zaalokować"<<std::endl;
  15. exit(EXIT_FAILURE);
  16. }
  17. add->value=value;
  18. add->next=NULL;
  19. if(f==NULL)
  20. f=add;
  21. else{
  22. Fifo *tmp=f;
  23. while(tmp->next!=NULL)
  24. tmp=tmp->next;
  25. tmp->next=add;
  26. }
  27. }
  28.  
  29. void print(Fifo *f){
  30. if(f==NULL) std::cout<<"Lista pusta";
  31. std::cout<<"[";
  32. while(f!=NULL){
  33. std::cout<<f->value<<",";
  34. f=f->next;
  35. }
  36. std::cout<<"]"<<std::endl;
  37. }
  38.  
  39. void set_mode(Fifo *&f,int mode){
  40. static bool actualMode=0;
  41. if(mode!=actualMode){
  42. reverse(f);
  43. actualMode=(!actualMode);
  44. }
  45. }
  46.  
  47. std::string get(Fifo &f){
  48. std::string tmp=f.value;
  49. Fifo *help=&f;
  50. f=*(f.next);
  51. delete help;
  52. return tmp;
  53. }
  54.  
  55.  
  56.  
  57. void reverse(Fifo *&f){
  58. Fifo *actual=f;
  59. Fifo *prev=NULL;
  60. Fifo *next=NULL;
  61. while(actual!=NULL){
  62. next=actual->next;
  63. actual->next=prev;
  64. prev=actual;
  65. actual=next;
  66. }
  67. f=prev;
  68. }
  69.  
  70. void deinit(Fifo *&f){
  71. if(f!=NULL){
  72. Fifo *tmp=f;
  73. while(tmp!=NULL){
  74. tmp=tmp->next;
  75. delete f;
  76. f=tmp;
  77. }
  78. }
  79. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:6:1: error: ‘Fifo’ does not name a type
 Fifo* init(){
 ^
prog.cpp:11:10: error: variable or field ‘put’ declared void
 void put(Fifo * &f,std::string value){
          ^
prog.cpp:11:10: error: ‘Fifo’ was not declared in this scope
prog.cpp:11:18: error: ‘f’ was not declared in this scope
 void put(Fifo * &f,std::string value){
                  ^
prog.cpp:11:32: error: expected primary-expression before ‘value’
 void put(Fifo * &f,std::string value){
                                ^
stdout
Standard output is empty