Hi.. I want to get the memory addresses of an array.i'm having a compilation error with this code.
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
int isu[1000];
void dhanu(void *(isu+996), void *(isu+995));
int main(){
*(isu+998)=isu;
*(isu+997)=(isu+10);
printf("%d\n",*(isu+998));
printf("%d\n",isu);
dhanu((isu+998),(isu+997));
}
void dhanu(void *(isu+996), void *(isu+995)){
printf("%d \n",(int *)(isu+996));
printf("%d \n",(int *)(isu+995));
error says:
error: In line 16 expected ‘)’ before ‘+’ token
error: In line 16 expected ‘;’, ‘,’ or ‘)’ before ‘void’
It works perfectly in this
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
int isu[1000];
void dhanu(void *a, void *b);
int main(){
//isu=(int)(isu+998);
*(isu+998)=isu;
*(isu+997)=(isu+10);
printf("%d\n",*(isu+998));
printf("%d\n",isu);
dhanu((isu+998),(isu+997));
}
void dhanu(void *a, void *b)){
printf("%d \n",(int *)a);
printf("%d \n",(int *)b);
So why can't we use void *(isu+996) instead of void *a !!