Writing a program using the Sieve of Tratosthenes theory and I cant covert void to int.
Heres my code:
#include <stdio.h>
#include <stdlib.h>
#define limit 1000000 /*size of integers array*/
void *malloc(size_t size)
int main(){
    unsigned long long int i, j;
    int *primes;
    int z = 1;
    int times;
    int counter;
    printf_s("Enter the limit: ");
    scanf_s("%d\n", ×);
    do (counter++) {
        primes = malloc(sizeof(int) * limit);
        for (i = 2; i < limit; i++)
            primes[i] = 1;
        for (i = 2; i < limit; i++)
            if (primes[i])
                for (j = i; i * j < limit; j++)
                    primes[i * j] = 0;
        printf("\nPrime numbers in range 1 to 100 are: \n");
        for (i = 2; i < limit; i++)
            if (primes[i])
                printf("%d\n", i);
    } while (counter <= times)
    return 0;
}
There error occurs in this line:
primes = malloc(sizeof(int) * limit);
Can someone point me to what Im doing wrong? Am I not using the correct library or is the function with "malloc()" coded incorrectly? This code in a C++ compiler, but I did research and saw it can work in a C compiled program. Thanks
 
    