I'm trying to make a sort function to sort the order of float value incompatible pointer. and when u run the code, after typing the size of pointed array and input the value, then the running just stopped. I do not know where the problem is, any one can help. I already corrected the warning, but still now result for running the code
#include <stdio.h>
#include <stdlib.h>
void sort(const int size, float *input, float *output);
int main(void) {
int a;
float *b=&b1;
float *c=&c1;
int i, i1;
printf("input the size\n");
scanf("%d", &a);
b=(float*)malloc(sizeof(int)*a);
c=(float*)malloc(sizeof(int)*a);
for(i=0; i<a ; i++){
scanf("%f", &b[i]);
}
for(i1=0; i1<a; i1++){
c[i1]=b[i1];
printf("%f\n", c[i1]);
}
sort(10, b, c);
free(b);
free(c);
return 0;
}
void sort(const int size, float *input, float *output)
{
void swap( float *element1Ptr, float *element2Ptr);
int pass;
int j;
int i0;
for (pass=0; pass<size-1;pass++)
{
for (j=0; j<size-1;j++){
if(input[j]>input[j+1]){
swap(&input[j], &input[j+1]);
}
}
}
for (i0=0; i0<size; i0++){
output[i0]=input[i0];
printf("%f", output[i0]);
}
}
void swap( float *element1Ptr, float *element2Ptr)
{
float hold=*element1Ptr;
*element1Ptr=*element2Ptr;
*element2Ptr=hold;
}