Error /bin/run.sh: line 4: 18 Segmentation fault (core dumped) ./exe

getting error /bin/run.sh: line 4: 18 Segmentation fault (core dumped) ./exe
my code is
#include <bits/stdc++.h>
using namespace std;

void findIndices(int input[], int size, int x, int output[], int &k, int currIndex){
if(currIndex==size){
return;
}
if(input[currIndex]==x){
output[k] = currIndex;
k++;
}
findIndices(input,size,x,output,k,++currIndex);
}

int allIndices(int input[], int size, int x, int output[]){
int k;
findIndices(input,size,x,output,k,0);
return k;
}

int main(){
int size;
cin>>size;
int input[size];
for (int i=0;i<size;i++){
cin>>input[i];
}
int x;
cin>>x;
int output[size];

int outputSize = allIndices(input,size,x,output);
for(int i =0;i<outputSize;i++){
	cout<<output[i]<<" ";
}

return 0;

}

hello @toshitvarshney11

initialise ur k with 0.

Aman Sir till same problem

pls save ur code here-> https://ide.codingblocks.com/
and share the link . it will check

initialise this k with 0.
i,e
int k=0;

sir i have tried int k=0; till same error

it is passing all the test cases. pls try submitting again.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.