Pointers

General discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
Toley
Posts: 922
Joined: 03 Sep 2008 16:17

Pointers

#1 Post by Toley » 03 Mar 2011 03:42

Can someone tell me why this give an error ?

Code: Select all

const int Values[] = {1,2,3,4,5};

void main(){
 int *ptr;
 ptr = &Values;
}
Serge T.
Learning is an endeless process but it must start somewhere!

User avatar
rajkovic
mikroElektronika team
Posts: 694
Joined: 16 Aug 2004 12:40

Re: Pointers

#2 Post by rajkovic » 03 Mar 2011 07:39

Toley wrote:Can someone tell me why this give an error ?

Code: Select all

const int Values[] = {1,2,3,4,5};

void main(){
 int *ptr;
 ptr = &Values;
}
It should not give error, we will fix this.
You can use workaround for a moment with explicit cast.

Code: Select all

const int Values[] = {1,2,3,4,5};

void main(){
int *ptr;
ptr = (int*)&Values;
}

Toley
Posts: 922
Joined: 03 Sep 2008 16:17

Re: Pointers

#3 Post by Toley » 03 Mar 2011 12:22

Thank you the workaround work perfectly :)
Serge T.
Learning is an endeless process but it must start somewhere!

Post Reply

Return to “mikroC PRO for PIC32 General”