I define an array and a function. The array is defined outside of the function. But I also have to use this inside the function. What do I need to do?
uint8_t array[] = { 1, 2, 3, 4 };
myfunction(){
//call index #2 of array
}
I define an array and a function. The array is defined outside of the function. But I also have to use this inside the function. What do I need to do?
uint8_t array[] = { 1, 2, 3, 4 };
myfunction(){
//call index #2 of array
}
Yes, you can do this. The array you declared has global scope, so it is available inside the function.
int arr[] = { 1, 2, 3, 4 };
void myfunction(){
printf("element is %d",arr[1]); //This is perfectly valid
}