School-Coding-Cpp/file/sort_example.cpp

29 lines
693 B
C++

/*
AUTORE: Manuel Vichi
Programmino di esempio che usa le sort
*/
#include <stdio.h>
#include <stdbool.h>
#include "fsorts.h"
int cmp_int(const void *a, const void *b) {
return (*(const int *)a) - (*(const int *)b);
}
int main(void) {
FILE* file = fopen("pincopallino.bin","r+b");
if (file != NULL){
// fQuickSort(file,0,7,sizeof(int));
fInsertionSort(file,sizeof(int),cmp_int);
fclose(file);
}
else
return -1;
// FILE* file = fopen("pincopallino.bin","wb");
// if (file != NULL) {
// int array[] = {1,5,3,7,2,9,4,0};
// size_t count = sizeof(array) / sizeof(array[0]);
// fwrite(array,sizeof(int),count,file);
// fclose(file);
// }
return 0;
}