Trying to take input from user, put it in array and do the sorting
The code is:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
class Sort
{
static int array[5];
static int index;
static int i;
public:
void insert(int num)
{
array[index] = num;
index++;
}
int sortarr(const void *x, const void *y)
{
return (*(int*)x - *(int*)y);
}
void doSort()
{
qsort(array, index, sizeof(int), sortarr);
for (i=0; i<index; i++)
{
printf("%d ", array[i]);
}
}
};
void main()
{
int j;
int number;
Sort s;
for(j = 0; j<=5; j++)
{
printf("Enter number = ");
scanf(&number);
s.insert(number);
}
s.doSort();
getch();
}
getting following errors
Error 1 error C3867: 'Sort::sortarr': function call missing argument list; use '&Sort::sortarr' to create a pointer to member e:\personal\brain mass\391331 - adt sort c\adt_sort\adt_sort\main.cpp 28 ADT_Sort
Error 2 error C2664: 'scanf' : cannot convert parameter 1 from 'int *' to 'const char *' e:\personal\brain mass\391331 - adt sort c\adt_sort\adt_sort\main.cpp 47 ADT_Sort