i am getting a segmentation fault at line 12. when i tried to print temp, it went in infinite loop. can you tell me the reason behind this and how to correct it(si-starting index, ei - end index)
using namespace std;
#include<iostream>
void partition(int arr[],int si,int ei)
{
int i,count=0, temp;
for(i=si+1;i<=ei;i++)
{
if(arr[si]>arr[i])
count++;
}
int index = count ;
temp= arr[si]; // here is the error
cout<<temp<< " ";
arr[si]=arr[index];
arr[index]=temp;
Use the debugger to trace through the code monitoring variable values so that you see what is happening during the code execution. When you find where the code is not executing as expected, then you have found a problem. Being able to use the debugger to find run-time problems in code is a skill that all programmers need to acquire. The sooner the better.