Hai, may i know what is the different between int* and int ? Or any links to explain it ?
Example:
int* iMsg[] = {I, N, T , I, A, K};
int iMsg[] = {I, N, T , I, A, K};
Hai, may i know what is the different between int* and int ? Or any links to explain it ?
Example:
int* iMsg[] = {I, N, T , I, A, K};
int iMsg[] = {I, N, T , I, A, K};
The code as written won't compile, as the syntax is incorrect. Keep in mind that a valid pointer can only have one of two values in it: 1) null, which means it points to nothing useful, and 2) a memory address. Therefore the statement:
int *myPtr[5];
defines an array of 5 pointers to integers. On the other hand, the statement:
int myIntegers[5];
is an array of 5 integers. As it stands, the array of pointers contains garbage because the elements have not been initialized to point to anything useful. You could do this:
int *myPtr[] = {&myIntegers[0], &myIntegers[1], &myIntegers[2],&myIntegers[3],&myIntegers[4]};
*myPtr[4] = 25;
The address of operator (&) resolves to the memory address of a data item. Given the code above, the five pointer elements have all been initialized to point to the five integers in myIntegers[]. Therefore, the last statement assigned the value of 25 into the memory address held in myPtr[4]. Since that element holds the memory address of myInegers[4], that element now holds 25. Read the pointer source mentioned earlier and then come back and read this. If it's still fuzzy, Beginning C for Arduino has two chapters devoted to just pointers. Maybe that would help, too.
As it stands, the array of pointers contains garbage
. . . unless it was declared at global scope, in which case it contains all nulls before "setup()" runs.