0

I am trying to debug a simple c++ program, which takes some inputs at the runtime. When i start debugging, it just stops where I should input the values. But after that it does not run. When i click on resume, still it does not. Can someone help me how can i get this debugged. Thank you so much.

#include "iostream"

using namespace std;

void selection_sort(int *a, int n){
    int i,j,temp,pos,smallest;
    for (i=0; i<n; i++){              ### i have a debug point here
        smallest = a[i];
        for(j=i; j<n; j++){
            if(smallest > a[j]){
                smallest = a[j];
                pos = j;
            }
        }
        temp = a[i];
        a[i]=smallest;
        a[pos] = temp;
    }
}

int main(){
    int arr[10],i;
    for (i=0;i<10;i++)     ## the eclipse debugger i.e. gdb stops here, as I have to input some values
        cin >> arr[i];
    selection_sort(arr,10);
    cout << "\nafter sorting:\n";
    for (i=0;i<10;i++)
        cout << arr[i] << " ";
    return 0;
}
`
DPR
  • 25
  • 6
  • And as it waits for you to input, did you input and press enter? – DeiDei Apr 18 '18 at 03:44
  • Possible duplicate of [Eclipse debugging with input from console](https://stackoverflow.com/questions/14324487/eclipse-debugging-with-input-from-console). Note: That question is a little outdated. Now, you just need to go into your debugging configuration, open the debugger tab, and enable the use external console option. You're going to have to do this for each project. – eesiraed Apr 18 '18 at 03:58
  • Also, C++ comments use `//`, not `##`. – eesiraed Apr 19 '18 at 00:37
  • And how do I enable the use of external console option? Thanks – DPR Apr 19 '18 at 02:33
  • I'm still stuck with this. Would appreciate any help on this. Thank you. – DPR May 10 '18 at 08:27

0 Answers0