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 !!

Recommended Answers

All 3 Replies

this is the 16th line..

void dhanu(void *(isu+996), void *(isu+995)){

What exactly were you expecting to happen? What you're attempting is rather nonsensical.

All the variables & pointers must declare within this array.
I take the address of the 1st element & the 11th element and assign 2 pointers to it((isu+997),(isu+998)).Then pass those 2 address two the

void dhanu

method by using another 2 ponters.. in that methoda i'm having a link list to store those addresses.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.