I am having a problem with returning the sorted value in the function sorted. I know it has something too do with fun pointers.
On a side note, how is a function suppost return something if it's declared as a void?
thanks a bunch!
/**
* helpers.c
*
* Helper functions for Problem Set 3.
*/
#include <cs50.h>
#include <math.h>
#include "helpers.h"
#include <stdio.h>
//Returns true if value is in array of n values, else false.
bool search(int value, int values[], int n)
{
...
}
// Sorts array of n values.
void sort(int values[], int n)
{
int bubbled = true;
int index = 0;
int count = 1;
while(bubbled)
{
count += 1; //if values[index] is less then values[index+1], up the count
if(values[index] > values[index+1])
{
values[index+1] = values[index];
count = 0; //and if not, restart
}
if (count == n)
{
bubbled = false;
}
}
printf("%i", values); //error: format specifies type 'int' but the argument has type 'int *' [-Werror,-Wformat]
}