A quick problem

Hello,

I have this problem. Whenever I try to compile this code, the program just blinks and closes without doing any action. Can't find anything wrong myself, so I came for help. I have bolded the code where something is wrong, don't pay attention to my Lithuanian comments.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include<iostream>
#include<fstream>

const char duom[] = "duom.txt";
const char rez[] = "rez.txt";
const char Max = 100;

using namespace std;

void Skaitymas(int A[],int B[],int & n,int & n2){
     ifstream ck(duom);
     
              ck >> n;
              
              for(int i=0; i<n; ++i){
                      ck >> A[i]; }
              ck >> n2;
              for(int z=0; z<n; ++z){
                      ck >> B[z]; }
                      ck.close(); }
                      
                      
void Rusiavimas(int A[],int B[],int & n,int & n2){
     for(int i=0; i<n2; ++i){ //ciklas prasidejo
             if(B[i] < 100 && B[i] >= 10){ //jei Rimo skaicius yra dvizenklis
                     
                     for(int p=0; p<n; ++p){ //ciklas prasidejo
                     
                             if(B[i] >= A[p]){ //pradedam paieska skaiciaus mazesnio arba lygaus Rasos relikvijai
                                     for(int o=n; o>=p; --o){
                                             A[o+1] = A[o]; }
                                             A[p] = B[i];
                                              ++n; } //paieska baigesi, i Rasos kolekcija pridetas skaicius
                                               } // ciklas baiges
                     for(int l=i; l<n2; ++l){
                             B[l] = B[l+1];
                             } //istrinam duomenis is Rimo masyvo
                                                } //Rimo skaicius nebe dvizenklis
                                                } //ciklas baigesi
     for(int r=0; r<n; ++r){ //ciklas prasidejo
             
             if(A[r] >= 100 && A[r] < 1000){ //jei Rasos skaicius dvizenklis
                     
                     for(int e=0; e<n2; ++e){ //ciklas prasidejo
                     
                     if(A[r] >= B[e]){ //pradedam paieska mazesnio arba lygaus skaiciaus
                             for(int c=n2; c>=e; --c){
                                     B[c+1] = B[c]; }
                                     B[e] = A[r];
                                     ++n2;
                                     } //ciklas baiges
                             
                        for(int x=r; x<n; ++x){
                             A[x] = A[x+1];
                             } //istrinam duomenis is Rasos masyvo
                                  
                             }
                     
                     }
                     
                     }
             
             } 
                                                 
                      
int main(){
    int Rasa[Max],Rimas[Max],n,n2;
    Skaitymas(Rasa,Rimas,n,n2);
    Rusiavimas(Rasa,Rimas,n,n2);
    ofstream ddd(rez);
    for(int i=0; i<n; i++){
            ddd << Rasa[i] << endl; }
            
            int pause;
            cin >> pause;
    
    return 0; }


Thank you in advance ;)

is this
1
2
            int pause;
            cin >> pause;


just for pausing the console, you could try
 
            std::cout<<std::flush;

before you use that OR you could try something like
 
            std::cin.get();


instead if it's just for pausing, another one i know is getch()...
Topic archived. No new replies allowed.