The following code runs fine while I'm using it in my Code blocks application. However, when solving the "Even Odds" problem in Codeforces by submitting the same code, it gives me a Compilation error.
Error:invalid conversion from 'void*' to 'long long int*' [-fpermissive]
I'm quite new to C programming. So, plz help me how I can fix this code of mine.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
long long *arr, n, k, i, n1, n2, m;
scanf("%I64d%I64d", &n, &k);
arr=malloc(sizeof(long long)*n);
n1=1;n2=2;
for(i=0;i<=n/2&&n1<=n;i++){
arr[i]=n1;
n1+=2;
}
if(n%2!=0) m=n/2+1;
else m=n/2;
for(i=m;i<=n&&n2<=n;i++){
arr[i]=n2;
n2+=2;
}
printf("%I64d", arr[k-1]);
free(arr);
return 0;
}