Answer the question
In order to leave comments, you need to log in
How to fix and what is the reason for stack smashing detected?
#include <stdio.h>
int get_max(int [], int );
int main(){
const int N = 14;
int arr[] = {};
int l;
l = get_max(arr, N);
return 0;
}
int get_max(int arr[], int size)
{
for (int i = 0; i < size; i++){
scanf("%d", &arr[i]);
}
int max = 0;
for (int i = 0; i < size; i++){
if(arr[i] > max){
max = arr[i];
}
}
printf("%d\n", max);
}
Answer the question
In order to leave comments, you need to log in
Please format the code normally, with indents. The array needs a size, but yours is zero. The get_max function does not return anything, even though the declared type is int.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question