# Thread: Why Need to cast??!!

1. ## Why Need to cast??!!

Code:
```#include <stdio.h>
#define min_range 0
#define max_range 100

void exchange(int *x, int *y)
{
int t = *x;
*x = *y;
*y = t;
}

void quick_sort(int *a, int p, int r)
{
int q;
if (p < r) {
q = partition(a, p, r);
quick_sort(a, p, q-1);
quick_sort(a, q+1, r);
}
}

int partition(int *a, int p, int r)
{
int x = a[r];
int j, i = p-1;
for (j = p; j < r; j++) {
if (a[j] <= x) {
i++;
exchange(&a[i], &a[j]);
}
}
exchange(&a[++i], &a[r]);
return i;
}

void generation(int *a, int n)
{
FILE *fData;
int i;
srand(time(NULL));
fData = fopen("quick-sort.dat", "wt");
for (i = 0; i < n; i++)
a[i] = rand()%(max_range-min_range+1)+min_range;
fprintf(fData, "%d\n\n", n);
for (i = 0; i < n; i++) {
if ((i % 10 == 0) && (i > 0)) fprintf(fData, "\n");
fprintf(fData, "%d ", a[i]);
}
fclose(fData);
}

void outputData(int *a, int n)
{
FILE *fData;
int i;
fData = fopen("quick-sort.out", "wt");
for (i = 0; i < n; i++) {
if ((i % 10 == 0) && (i > 0)) fprintf(fData, "\n");
fprintf(fData, "%d ", a[i]);
}
fclose(fData);
}

int main()
{
int *a;
int i, size;
printf("size = ");
scanf("%d", &size);
a = malloc(size*sizeof(*a));
generation(a, size);
quick_sort(a, 0, size-1);
outputData(a, size);
return 0;
}```
Code:
```quick-sort.c: In function `main':
quick-sort.c:71: warning: assignment makes pointer from integer without a cast```
I have read CProgramming F&Q. In this case, i need not to cast pointer a. Why there has warning about casting?!

2. Probably because you are using a C++ compiler not C.

3. try including stdlib.h