please helpme

hi, emm I don't understand but, my program on the moment to run, say : segmentation fault, and I don't know what to do, please help
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
using namespace std;

int mistery (int avalues[], int ienigma, int in, int IN){

	if (in == IN ) {
	return ienigma;}

	else {
		if (avalues[in] > ienigma){
		ienigma=avalues[in];}

	mistery (avalues,ienigma, in+1, IN);}

}

1
2
3
4
5
6
7
8
9
10
11
12
13
int main () {
	int n;
	int avalues [n];
	cin>> n;

	for (int i=0 ;i<n; i++) {
	avalues [i]= i+1; }


	cout<< mistery (avalues, -2, 0, n);


return 0;

Your variable n isn't properly initialized. So its value may be undefined, and so the size of the array avalues.
thanks, a friend does tell me who's the problem, thanks tcs
Topic archived. No new replies allowed.