I just wrote some code for a bubble sort function. I would like to test it using a simple printf with an array of values passed into it but am struggling. For now, let's assume that this file is independent (not linked to any header as implementation). Please see code and error message below.
include
include
int main(int values[]) { int n = 5 ; values[] = {3,4,1,5,2} ; bool iter ; // O(n^2) sorting algorithm do { iter = false ; for (int i = 0; i < n-1 ; i++) { if (values[i] > values[i + 1]) { int temp_val = values[i] ; values[i] = values[i + 1] ; values[i + 1] = temp_val ; iter = true ; } } } while (iter == false) ; return ;
// prints the array to test if the function is working correctly
for (int i = 0; i < n ; i++)
{
printf("%d, ", values[i]) ;
}
printf("\n") ;
}
THE ERROR THAT I GET IS: error: first parameter of 'main' (argument count) must be of type 'int' int main(int values[]) ^ test.c:16:12: error: expected expression values[] = {3,4,1,5,2} ; ^ test.c:16:16: error: expected expression values[] = {3,4,1,5,2} ; ^ test.c:33:5: error: non-void function 'main' should return a value [-Wreturn-type] return ;